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

Hello monks!

This question doesn't really have a lot to do with Perl, but I am using Perl so I hope it's permissible to ask this here.

I am writing a Perl CGI program, which uses cookies, and I was just wondering what the correct way to format the expiration date is. When I use google and some books that I have, all of the answers are different. I gather that most browsers will accept several formats without complaint, but what is the official one?
  • Comment on Correct expiration date format for cookies

Replies are listed 'Best First'.
Re: Correct expiration date format for cookies
by davorg (Chancellor) on Aug 14, 2006 at 07:44 UTC

    The documentation for's "header" method contains an example of the format required - Thursday, 25-Apr-1999 00:40:33 GMT. But it's usually easier to use one of the abbreviated formats like '+1d' or '+1y'.


    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Correct expiration date format for cookies
by Tomte (Priest) on Aug 14, 2006 at 08:30 UTC

    According to the RFC 2965 Max-Age for a cookie is expressed as positive integer with the meaning "seconds from now on" - in difference to the cache-controling expiration header, which has to follow the date-formats specified in RFC 2616, of which the format mentioned in the is one.


    An intellectual is someone whose mind watches itself.
    -- Albert Camus