Perl CGI  «Prev  Next»

Lesson 11Expiring cookies
ObjectiveExamine how to Expire a Cookie in Perl.

Examine how to Expire a Cookie in Perl

Cookie persistence


Set cookie: UserID=007; Expires=Mon, 01-Jan-2001 00:00:00 GMT

In RFC-2109 cookies, you set the expiration date by specifying how many seconds the cookie should stay in effect:
Set cookie: UserID=007; Max-Age=157766400; Version=1

The Max-Age element is the number of seconds for the cookie to age before it expires. (That is correct: There are 157,766,400 seconds in five years, assuming one leap year.)