setcookie with expire=0 does not expire after the browser closes

14,347

oh... this is because I activated "Continue where I left off" in chrome://chrome/settings/.

See here

Share:
14,347
Timespace
Author by

Timespace

Updated on July 03, 2022

Comments

  • Timespace
    Timespace almost 2 years

    I use setcookie to make a cookie with expire=0. From the PHP document, (link)

    The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number ?of seconds before you want it to expire. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

    My php code:

    setcookie('option', 'yes', 0, '/');
    

    However, the cookie does still not expire (still can be accessed) when I close and re-open the browser(chrome but not firefox).

    How do I make the cookie expires when the browser is closed?