cookie expiration

9 views
Skip to first unread message

xrfang

unread,
Nov 5, 2009, 8:50:55 PM11/5/09
to web.py
According to the doc, if I do this:

web.setcookie(name, value)

The cookie will be permanent. But when doing this, I found that the
cookie, if no expire is set, is session cookie. I think this is a
mistake in the doc. How can I set permanent cookie?

Thanks

alexander lind

unread,
Nov 5, 2009, 11:25:45 PM11/5/09
to we...@googlegroups.com
by adding an integer for the expiry field?

xrfang

unread,
Nov 5, 2009, 11:52:28 PM11/5/09
to web.py
Yes, but that integer cannot be infinity :) That of course can be
solved easily, but I wonder if there is an "original" way to do it
(set permanent cookie)?

Adam Atlas

unread,
Nov 6, 2009, 12:00:31 AM11/6/09
to we...@googlegroups.com
If I remember correctly, HTTP doesn't support literally permanent
cookies. I think the standard way is to set an expiry date distant
enough that your users will expire before the cookie does.

alexander lind

unread,
Nov 6, 2009, 12:03:46 AM11/6/09
to we...@googlegroups.com
Do you really need the cookie to stay until the sun decays and
swallows up the earth in a fiery embrace in like 4 billion years? If
so you are out of luck, because cookies can only be set with set
expiry. You can make it like 10 years from now. Something tells me
that will be enough for you :)

Alec

alexander lind

unread,
Nov 6, 2009, 12:05:36 AM11/6/09
to we...@googlegroups.com
yeah no such thing as infinite cookies are supported.

Anand Chitipothu

unread,
Nov 6, 2009, 12:07:13 AM11/6/09
to we...@googlegroups.com
2009/11/6 alexander lind <al...@polkabrothers.com>:

>
> Do you really need the cookie to stay until the sun decays and
> swallows up the earth in a fiery embrace in like 4 billion years?  If
> so you are out of luck, because cookies can only be set with set
> expiry. You can make it like 10 years from now. Something tells me
> that will be enough for you :)

or

web.setcookie('name', 'value', expires="Fri, 31-Dec-9999 23:59:59 GMT")

Even unix calender complains to go beyond year 9999. :)

Anand

alexander lind

unread,
Nov 6, 2009, 12:21:52 AM11/6/09
to we...@googlegroups.com

That way the mutated cyborg lizard men that will have taken over the
earth by then will still be logged in on your site at least until the
11th millennium begins.
:)

Alec

xrfang

unread,
Nov 6, 2009, 2:57:04 AM11/6/09
to web.py
Well then I have modified that cookbook page :)

Thanks

On 11月6日, 下午1时07分, Anand Chitipothu <anandol...@gmail.com> wrote:
> 2009/11/6 alexander lind <a...@polkabrothers.com>:
Reply all
Reply to author
Forward
0 new messages