|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
anyone know how to set a permanent cookie ?
Hi
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 ? Cheers, Eli |
|
#2
|
||||
|
||||
|
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?Mark. |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
|||
|
|||
|
coookie expiration
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) |
|
#5
|
||||
|
||||
|
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
![]() Mark. |
|
#6
|
|||
|
|||
|
I was able to find the answer to my own quesion on this page:
http://www.modpython.org/pipermail/...une/000692.html There are three options that can be configured: CookieExpires, CookieName and CookieTracking... CookieExpires 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. |
|
#7
|
|||
|
|||
|
Ummm ... how do i set the cookie expires value ?
Do you have an example bit of code by chance? Cheers Eli |
|
#8
|
|||
|
|||
|
cookie["name"]["expires"]=3600
where 3600 is the number of seconds you want it the cookie to last. (3600 would be for one hour). |
|
#9
|
|||
|
|||
|
ahhh.... Thank you for that
I don't know why it was so hard for me to find that when searching. cheers, Eli |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > anyone know how to set a permanent cookie ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|