Differences between revisions 1 and 2
Revision 1 as of 2006-03-28 14:42:56
Size: 371
Editor: qingfeng
Comment: Python通用Cookie操作方式
Revision 2 as of 2009-12-25 07:11:05
Size: 371
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

适合于所有的python framework

写Cookie

Toggle line numbers
   1 c1=Cookie.SimpleCookie()
   2 c1["user"]="qingfeng"
   3 c1["user"]["max-age"]=3600
   4 c1["user"]["expires"]=3600
   5 os.environ["HTTP_COOKIE"] = str(c1)

读Cookie

Toggle line numbers
   1 c2=Cookie.SmartCookie(os.environ["HTTP_COOKIE"])
   2 #c2.load(os.environ["HTTP_COOKIE"])
   3 return "<pre>%s</pre>"%(c2["user"].value,)

PythonAndCookie (last edited 2009-12-25 07:11:05 by localhost)