cookie

Topic: 
 

เอามาจาก ug's Python CGI scripts: cookie.py

การเซ็ต Cookie
สร้างไฟล์ชื่อ setcookie.py

#!/usr/bin/env python
import Cookie

c1 = Cookie.SimpleCookie()
# Create a cookie in c1
# This will be temporary and will disappear when the session is closed
c1["cracker"] = "hello"
# The RFC says you should always set this but it seems to work ok without it
c1["cracker"]["version"] = 1

# Create another one
c1["bisquit"] = "whatever"
# Make the browser store it for one hour
c1["bisquit"]["max-age"] = 3600 # Time to keep, in seconds
c1["bisquit"]["expires"] = 3600 # Obsolete, but Netscape still seems to require it
c1["bisquit"]["version"] = 1

# Print the headers that sets the cookies
Subscribe to RSS - cookie
 

Syndicate

Subscribe to Syndicate

Who's online

There are currently 0 users online.