October 13th, 2003, 09:55 PM
anyone know how to set a permanent cookie ?
I've tried for a while now .. but can't find it anywhere when I search, but does anyone know how to set a cookie so that it's stay set between different browser sessions ?
October 14th, 2003, 03:24 AM
I don't think any cookie can be "permanent", cookies by nature get deleted or eaten, go moldy etc . I'm not sure but chouldn't you just give the cookie an unusually long best before date?
October 14th, 2003, 09:02 AM
as said cookies can't be made to persist forever,
maxAge is what you want to set.
positive integers are how long the cookie persists in seconds, i think it's 32 bit so the biggest you could put in is 2^32 which is roughly 40,000 years NOTE! most browsers do not allow this, for some bizarre reason they max out at one year, going above this seems to invalidate the cookie and it dissappears as soon as the browser is closed, so use 60*60*24*365 = 31536000
set maxAge to -1 if you want it to persist until the browser closes
set to 0 and it will expire immeadiatly
October 14th, 2003, 09:22 AM
What if you don't set an expiration or maxage?
What does python cookies default to?
I thought if this wasn't set a cookie would survive as long as the user allowed it to, (of course I haven't tested this with Python's cookie it's just my experience with cookies in general)
October 14th, 2003, 09:32 AM
Python's cookie module really just constructs and sends a cookie header to your web browser, if no expiration date is set then i'm guessing that no time or current time is used. I did look at the doc's on the Cookie module quickly but i didn't see anything on this subject. So, the cookie should expire imediatly or after the browser is closer.. just a guess though
October 14th, 2003, 03:07 PM
I was able to find the answer to my own quesion on this page:
There are three options that can be configured: CookieExpires, CookieName
This option sets an expiration time for the cookie generated by this module.
This time can be either a number of seconds or a string describing the
amount of time. If this option does not exist the cookie will expire when
the browser's session does....
so you were right Mark.
October 17th, 2003, 01:24 PM
Ummm ... how do i set the cookie expires value ?
Do you have an example bit of code by chance?
October 17th, 2003, 02:45 PM
where 3600 is the number of seconds you want it the cookie to last. (3600 would be for one hour).
October 17th, 2003, 10:00 PM
ahhh.... Thank you for that
I don't know why it was so hard for me to find that when searching.