[thelist] Need help with perl cookie prob

Keith cache at dowebscentral.com
Fri May 3 08:27:01 CDT 2002

At 09:14 PM Thursday 5/2/02, Chris wrote:
>Hello all.
>I am using some code I found that places a cookie on my user's system.  I
>have the cookie set to expire after 1 year, but they are disappearing on
>the day after they are set.

Setting cookie expiration requires that you set a future date that actually
will exist according to the browser's built-in date function. Here's the
snippet that I use for setting a cookie that expires one year from now. It
gets the time stamp from the OS, adds 365 X the number of seconds in a day
and lets Perl convert it to a GMT time format.

$date = time + 365 * 86400;
$expire = gmtime($date);

print "Set-Cookie: $name=$value;expires=$expire;path=/\n";


cache at dowebscentral.com

More information about the thelist mailing list