Why can't I delete cookies ????? The MVC framework is used to set the COOKIE in the action of a controller: PHPcodesetCookie (isLogin,); setCookie (nickName, $ result [0] [nickname], 0 ,); setCookie (integral, $ result, why can't I delete the COOKIE ?????
The MVC framework is used to set the COOKIE in the action of a controller:
PHP code
setCookie('isLogin', 1, 0, '/');setCookie('nickName', $result[0]['nickname'], 0, '/');setCookie('integral', $result[0]['integral'], 0, '/');
Then, the COOKIE is output in another action:
PHP code
setCookie('isLogin', '', time()-100);setCookie('nickName', '', time()-100);setCookie('integral', '', time()-100);
However, the COOKIE is not successfully deleted ~ If var_dump ($ _ COOKIE) is used to print isLogin and other values, why?
Thank you!
------ Solution --------------------
Do you understand the principle of cookie?
First, if you request a remote server page for the first time, and then if the browser finds that there is a Set-Cookie item in the return header (php's setcookie function can be used to do things, or the header function can also be used ), the browser will know how long the cookie will expire, the server file path, valid domain name, and so on... Then, the second time you request the same server (based on the domain name), the browser will check the cookie that the last server called me to save, and I will check it again, if no expired Cookie is sent to the server, the server can obtain the cookie value sent from the client based on the http request header, then, initialize the $ _ COOKIE array based on these values.