Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookie timeout

Status
Not open for further replies.
May 22, 2002
63
0
0
GB
Hi,

Can anyone explain how to make a cookie last 1hr but to erase on browser close?

Thanks,

Anderz
 
You can't do both.

A cookie can have one expiration. If that expiration is not set at all, the browser assumes the cookie will only last for the current session. If an expiration is set, then the browser assumes the cookie is good until it expires.

One workaround would be to use a cookie with no expiration, then provide in your PHP code the logic to invalidate that cookie after a certain period of time.

For example, in a session (which relates to a "current session" cookie on the browser) you could add a variable which states when the session was first was created. Then have your code ignore, invalidate, or remove the session variables for that session once a certain amount of time has passed.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top