0

I have read the following tutorial: How do I expire a PHP session after 30 minutes?

But is it necessary to set session.cookie_lifetime to 0? If necessary, when should we set it ?

I do not want to spoil that useful tutorial by asking question there.

Community
  • 1
  • 1
Vpp Man
  • 2,387
  • 7
  • 40
  • 66

1 Answers1

0

it is necessary to set the expiration as an expiry date in seconds (UTC format), not a timespan from current time, so use

time()+(60*30)

for expiry date parameter. time function outputs current time in seconds, and you are adding seconds to it if you set it to 0 cookie will expire when client closes his browser

Uğur Gümüşhan
  • 2,387
  • 4
  • 33
  • 59
  • So this should be done during user successfully logins or on each page is loaded? Using [setcookie()](http://php.net/manual/en/function.setcookie.php) before outputting any HTML ? – Vpp Man Nov 19 '11 at 07:46