[Techtalk] At Wits' End on Persistent HTTP Cookies

David Merrill david at lupercalia.net
Tue Apr 30 16:14:43 EST 2002


On Tue, Apr 30, 2002 at 01:02:54PM -0700, Kai MacTane wrote:
> Hi. I'm trying to make a mod_perl/Mason project set a persistent cookie, 
> using the old Netscape cookie spec at 
> http://www.netscape.com/newsref/std/cookie_spec.html . I can make it set a 
> session cookie, no problem, but getting to keep the cookie around for a 
> mere 5 days has driven me to the point of insanity.

Have you tried the "+10d" format rather than a hard coded date? All I
can tell you is that that kind of format works for me.

Are you using CGI.pm? If so, here is what I'm doing:

#START
use CGI;
my $CGI = new CGI;
my $session_id = ( a random text string, not pertinent )
my $cookie=$CGI->cookie(-name    => 'lampadas_session',
                        -value   =>$session_id,
                        -expires => '+1M');
print $CGI->header(-cookie=>$cookie,-expires=>'now');
#END

NOTE: +1M means expire in 1 month.

HTH,

-- 
David C. Merrill                         http://www.lupercalia.net
Linux Documentation Project                   david at lupercalia.net
Lead Developer                                 http://www.tldp.org

Microsoft has that certain confidence that comes from enjoying a monopoly
and being very good at its business, which leads it to believe that it can
do anything. Microsoft and its employees now think it is indeed the Master
of the Universe.
	--Stewart Alsop, Fortune



More information about the Techtalk mailing list