我熟悉在Python中分配,创建cookie.但我不确定如何创建一个将持续到当前浏览器会话关闭的cookie(所以我有一个非常基本的方式来告诉用户何时返回我的网站).
那么我设置哪个cookie标头以确保在Python中关闭浏览器时cookie将过期/删除?我是否使用SimpleCookie对象或其他对象?
这个帖子说我在PHP中设置了cookie_lifetime标志/标题,但对于python呢?http://bytes.com/topic/php/answers/595383-how-declare-cookie-will-destroy-after-browser-closed
这会创建一个在关闭浏览器时到期的cookie吗?
cookie = Cookie.SimpleCookie()
cookie["test"] = "MYTEST"
cookie["test"]['expires'] = 0 # or shd I set the max-age header instead?
print str(cookie) + "; httponly"
Run Code Online (Sandbox Code Playgroud)