rsiedl has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Basically the title says it all.
Is it possible to set the "expire" attribute of CGI::Cookie to never?

Cheers,
Reagen
  • Comment on Can CGI::Cookie be set to never expire?

Replies are listed 'Best First'.
Re: Can CGI::Cookie be set to never expire?
by matthewb (Curate) on Nov 16, 2004 at 14:17 UTC

    You could set the expiry date to ten years in the future but what if the user deletes all their cookies for some reason?

    In practice the answer is, "not in any way you can count on".


    MB
      ok. Thanks MB.
Re: Can CGI::Cookie be set to never expire?
by bart (Canon) on Nov 16, 2004 at 14:37 UTC
    I don't think so, I don't think the cookie header command set includes that option — though you can set the expires field a very long time into the future. (Pass a formatted date instead of an maximum age, it'll just use it.)

    Why do you want it, anyway? Do you expect people to still be using the same computer and browser, in 10 years time? Do you still expect to recognize them when they come back for the first time, after your cookie has expired, years from now? Does it even matter?

    For people that frequent your site often enough, I'd simply refresh the cookie once in a while. That way, for regular visitors, the cookie will effectively never expire.

Re: Can CGI::Cookie be set to never expire?
by borisz (Canon) on Nov 16, 2004 at 14:21 UTC
    Set expire to a high value
    ... -expires => '+99y', ...
    Boris