Alex Reynolds
Alex Reynolds

Reputation: 96986

How to test if a Perl CGI::Cookie cookie is almost about to expire?

If the cookie is between 0 and x minutes away from expiration, I would like to refresh the expires value of that cookie to some set value (if the cookie is already expired, I do not want to refresh it).

How would I accomplish this with CGI::Cookie and CGI.pm?

Upvotes: 1

Views: 862

Answers (2)

ysth
ysth

Reputation: 98398

Cookies sent by the browser do not expose their expiration time; they are either sent or they aren't. To know when it is going to expire, you have to store the expiration time in the cookie value in some parseable form.

Upvotes: 2

Quentin
Quentin

Reputation: 944203

If the cookie has been set, then it will be sent to the server. If it has expired, then it won't be.

Just test to see if the cookie exists, and refresh it if it exists.

Upvotes: 1

Related Questions