Create A Cookie That Lasts Until The Browser Is Closed(session Cookie?)
I am familiar with assigning, creating cookies in Python. But I am unsure how to create a cookie that will last until the current browser session is closed(so I have a very rudimen
Solution 1:
Just leave out the "expires" value altogether, i.e. don't set it to anything. See the Wikipedia entry for details:
Set-Cookie: made_write_conn=1295214458; path=/; domain=.foo.com
[...]
The second cookie made_write_conn does not have expiration date, making it a session cookie. It will be deleted after the user closes his/her browser
In Python:
In [11]: from Cookie import SimpleCookie
In [12]: c = SimpleCookie()
In [13]: c['test'] = 'MYTEST'
In [14]: print c
Set-Cookie: test=MYTEST
Solution 2:
Mack,
Your answer looks correct to me. Setting "expires" = 0 on the Morsel object should do what you want. Have you tested it?
Looks like max-age is not supported by IE:
Post a Comment for "Create A Cookie That Lasts Until The Browser Is Closed(session Cookie?)"