简体   繁体   中英

PHP cookie expire

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=';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM