dagurp at heimsnet.is
dagurp at heimsnet.is
Fri Feb 4 19:00:08 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. If you read it more carefully you'll see that you can use a numeric value. In fact that's what they do in the examples. I did try to use the Netscape format however but it always gave me errors.
|