+ 2
How to set cookies using python scripting?
I wish to develop a web application
2 ответов
+ 7
#!/usr/bin/env python import Cookie import datetime import random expiration = datetime.datetime.now() + datetime.timedelta(days=30) cookie = Cookie.SimpleCookie() cookie["session"] = random.randint(1000000000) cookie["session"]["domain"] = ".jayconrod.com" cookie["session"]["path"] = "/" cookie["session"]["expires"] = \ expiration.strftime("%a, %d-%b-%Y %H:%M:%S PST") print "Content-type: text/plain" print cookie.output() print print "Cookie set with: " + cookie.output()
(http://jayconrod.com/posts/17/how-to-use-http-cookies-in-python)
+ 1
thank you