Why can't I delete cookies? Solution

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.