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

Re: [MacPerl] Cookie Expiry question



At 11:49 -0400 5/10/99, Ronald J. Kimball wrote:
>
> What is strange about this is that 1241299336 is not a proper format for
> HTTP dates.

I also saw a "real" formatted date when I ran the code, not seconds...

>In other words, as far as I can tell this is a bug in CGI.pm.

Or an older way to do it. But I don't think it's either actually; there's
something else going on.

>>      And seconds-since-epoch...what does this refer to?
>
> Computers store dates as number of seconds since the epoch.  On Unix
> systems, the epoch is Midnight, Jan 1, 1970.  On Macs, it's Midnight, Jan
> 1, 1900 (I think :).

1904 actually. When a Mac rolls back to 0 it hits Dec. 31, 1904.
The story goes that this date "looked good" for some numerological reason
:-)

> just use numeric comparison, but it is not a good format for expiration
> dates in HTTP cookies, because it's just not the right format.

Well "right" is arguable, but it's certainly not expected or documented!

> You might try opening the CGI.pm file in your text editor and seeing if a
> version is specified anywhere...

print $CGI::VERSION;

Current (most recent) version of CGI.pm is 2.50 available from CPAN and
Lincoln Stein's web site, and from www.wiley.com/compubooks/stein. The
version included with MacPerl 5.2.0r4 is 2.36.

> But anyway, MacPerl is already several years old,

just over 1 year, actually; 5.2.0r4 was released in time for the release of
the MacPerl book which went to press last April/May in time for WWDC :-)

>as are the modules packaged with it...

Possibly older.

> So I would not be
> surprised if this problem with cookie expirations is a bug in an old
> version of CGI.pm.

I don't think it's a bug, at least not in CGI.pm 2.36...

use CGI;


     $cookie1 = CGI->cookie(-name=>'fc',
               -value=>"chocolate chip",
               -expires=>'+10y');

     print CGI->header(-cookie=>$cookie1);

prints

  Set-cookie: fc=chocolate%20chip; expires=Thu, 07-May-2009 17:55:21 GMT

  Date: Mon, 10 May 1999 17:55:21 GMT

  Content-type: text/html

under CGI.pm 2.36; However, the code

  $expires = CGI::expires("+10y");
  print $expires, "\n";

gave me an error:

  # Undefined subroutine CGI::expires

Version 2.5 of CGI.pm prints what I expect for this last bit o' code

   Thu, 07 May 2009 18:02:39 GMT


(-: how come we're still doing CGI stuff in the main list? :-)

- Vicki

-- --
       |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
 ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
      |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
     '---''(_/--'  `-'\_) http://www.cfcl.com/~vlb  http://www.macperl.org

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