开发者

PHP cookie expire

开发者 https://www.devze.com 2023-02-21 18:46 出处:网络
Okay, when logging in I simply set a cookie to true and开发者_开发问答 set it to expire in a fortnight. but if the user wants to logout, how do I edit that cookie to say false or just make it go away

Okay, when logging in I simply set a cookie to true and开发者_开发问答 set it to expire in a fortnight. but if the user wants to logout, how do I edit that cookie to say false or just make it go away by expiring it?


Use setcookie() again. You can either set it's value to false or make it expire in the past. Both should have the desired effect.


From PHP:

setcookie('yourCookie', '');

You can also do it in JavaScript

document.cookie='yourCookie=';
0

精彩评论

暂无评论...
验证码 换一张
取 消