Lesson 11 | Expiring cookies |
Objective | Examine how to Expire a Cookie in Perl. |
Examine how to Expire a Cookie in Perl
Cookie persistence
By default, cookies are persistent only as long as the browser is open. In order for the cookie to remain in the browser even after the browser has been closed, you must explicity tell the cookie how long to stay around. This is the most significant difference between the Netscape cookie specification and RFC-2109. In Netscape cookies, you expire a cookie by telling the browser on what date the cookie should expire:
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.)