Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 13th, 2003, 08:55 PM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 6
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

Reply With Quote
  #2  
Old October 14th, 2003, 02:24 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old October 14th, 2003, 08:02 AM
whitelines's Avatar
whitelines whitelines is offline
action=(isSleep())?sleep:code;
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Sydney->Indiana
Posts: 182 whitelines User rank is Corporal (100 - 500 Reputation Level)whitelines User rank is Corporal (100 - 500 Reputation Level)whitelines User rank is Corporal (100 - 500 Reputation Level)whitelines User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 15 h 8 m 29 sec
Reputation Power: 9
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
__________________
/*
* www.benjaminranck.com
* bjamins.blogspot.com
*/

Reply With Quote
  #4  
Old October 14th, 2003, 08:22 AM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
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)

Reply With Quote
  #5  
Old October 14th, 2003, 08:32 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #6  
Old October 14th, 2003, 02:07 PM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
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.

Reply With Quote
  #7  
Old October 17th, 2003, 12:24 PM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 6
Ummm ... how do i set the cookie expires value ?
Do you have an example bit of code by chance?

Cheers
Eli

Reply With Quote
  #8  
Old October 17th, 2003, 01:45 PM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
cookie["name"]["expires"]=3600

where 3600 is the number of seconds you want it the cookie to last. (3600 would be for one hour).

Reply With Quote
  #9  
Old October 17th, 2003, 09:00 PM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 6
ahhh.... Thank you for that

I don't know why it was so hard for me to find that when searching.

cheers,
Eli

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > anyone know how to set a permanent cookie ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway