[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Cookie Expiry question



Chris Cummer wrote:
> 
> Ronald J. Kimball wrote:
> 
> >> I've just started using CGI.pm and in the docs it states that:
> >> 
> >>      (CGI::expires() is the static function call used 
> >>      internally that turns relative time intervals into 
> >>      HTTP dates....)
> >> 
> >> When used, this creates an expiry date in the cookie of format:
> >> 
> >>      1241299336
> >> 
> >> Could someone please point me to an explanation of how this number is 
> >> determined? What is the format of this HTTP date?
> >> 
> >
> >Could you show us how you used CGI::expires() to create this date?
> 
> Certainly - through the following
> 
>      $cookie1 = $q->cookie(-name=>'fc',
>                -value=>"$username:$password",
>                -expires=>'+10y');
> 
> print $q->header(-cookie=>$cookie1);
> 
> In which the expiry date is obviously set to ten years into the future 
> (which is probably not the date result I mentioned above, I just grabbed 
> that from an arbitrary cookie in the prefs).
> 
> I'm reasonably certain I'm using the CGI.pm module correctly, but it's 
> the date's format I'm curious about. What's happening inside 
> CGI::expires()? Is there a standard to this format?
> 

I plugged the code above into a short script, and got the following output:

Set-cookie: fc=Joe%3Atruck7; expires=Thu, 07-May-2009 14:48:13 GMT
Date: Mon, 10 May 1999 14:48:13 GMT
Content-type: text/html

As you can see, the expiration date is 
  Thu, 07-May-2009 14:48:13 GMT
in the same format as the date in the Date: header.


Strangely, your result appears to be in seconds-since-epoch:
1241299336 => Sat May  2 17:22:16 2009


What version of CGI.pm are you using?

Ronald

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org