I’m trying to set a cookie with:
setcookie($cookie_name, $val, 0);
Or
setcookie($cookie_name, $val);
But when I close and re-open the browser (firefox, chrome) the cookie is still alive with the same value. How can I force it to delete when visit is over?
Thank you
To delete a cookie just set the expiry date to the past like so:
However, I do not think this is the issue in your case, as your code seems to be correct.
How are you testing for the cookie? You are probably setting it again before testing for it!
You will also want to make sure you are closing the browser not the tab. Closing a tab, does not end a session!