[mod_python] Cookie problem

Jon-Pierre Gentil jgentil at sebistar.net
Fri Feb 4 13:09:54 EST 2005


On Friday 04 February 2005 11:06 am, dagurp at heimsnet.is wrote:

> Hi,
> I create a cookie and set it to expire in 2 weeks like this:
>
>  cookie = Cookie.Cookie('foo', bar)
>  cookie.expires = time() + 1209600  # 2 weeks
>  Cookie.add_cookie(req, cookie)
>
> But whatever I set "expires" to it is always set to "end of session".
> I also tried doing this: Cookie.add_cookie(req, 'foo', bar,
> expires=time() + 1209600)

From the documentation:

The expires attribute is a property whose value is checked upon setting to 
be in format "Wdy, DD-Mon-YYYY HH:MM:SS GMT" (as dictated per Netscape 
cookie specification), or a numeric value representing time in seconds 
since beginning of epoch (which will be automatically correctly converted 
to GMT time string). An invalid expires value will raise ValueError.

Therefore, you cannot set it to time.time().  You'll need to create a 
strftime string for it.



-- 
_________________________________________________________

  Jon-Pierre Gentil               PGP: 0xA21BC30E
  jabber: jgentil at sebistar.net    web: www.sebistar.net
  "If you think education is expensive, try ignorance."
_________________________________________________________ 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050204/ee19f1e3/attachment.bin


More information about the Mod_python mailing list