0

It seems that when I try to keep my session cookie, it deletes itself on browser close. The cookie params are set for a lifetime of 0. But when I go in to check it out, the cookie is not there. What is going on here?

1
  • 1
    when you set lifetime at 0, cookie is deleted when you close your browser Commented Feb 7, 2012 at 19:57

2 Answers 2

2

If its lifetime is set to 0, the cookie deletes itself when closing the browser. If you want to keep it alive for longer, you need to specify a time, such as 5h or 12m oder 8y.

Use something like this for the time value:

time()+60*60*24*30 

In this case the cookie would last 30 days (60-seconds * 60-minutes * 24-hours * 30-days)

Sign up to request clarification or add additional context in comments.

Comments

2

when you set lifetime at 0, cookie is deleted when you close your browser

try set a fix value and you should fix your problem.

source : http://php.net/manual/en/function.setcookie.php

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.