Reputation: 3
I have created a cookie and want it to expire after 10seconds. However, it doesn't work. I have tried to close the browser but the data still here.
This is the code I set for the cookie.
setcookie('attempt','', time()+10);
Upvotes: 0
Views: 320
Reputation: 5639
We have no idea where and how your setcookie()
method is called, but it is server side in each case. So when you reload the site after closing the browser, the script is executed again and so the cookie is also sent again.
You can also set cookies on the client side (which i'd prefer):
https://www.w3schools.com/js/js_cookies.asp
Upvotes: 2