How does PHP delete cookies?

Source: Internet
Author: User
{Code...} the above code is the {code...} that generates cookies. Using the above code, the Cookies specified by name $ authcookiename cannot be cleared? Solution
setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);setcookie($auth_cookie_name, $auth_cookie, $expire, '/', COOKIE_DOMAIN, $secure, true);setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, '/', COOKIE_DOMAIN, $secure_logged_in_cookie, true);
The above code generates cookies.
setcookie($auth_cookie_name,'');

The above code cannot clear name as $ authCookieCookie specified by name?

Solution

Reply content:
setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);setcookie($auth_cookie_name, $auth_cookie, $expire, '/', COOKIE_DOMAIN, $secure, true);setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, '/', COOKIE_DOMAIN, $secure_logged_in_cookie, true);
The above code generates cookies.
setcookie($auth_cookie_name,'');

The above code cannot clear name as $ authCookieCookie specified by name?

Solution

Set the validity period to a previous time.You can delete cookies. Also, @ MarlinMarlin says,

When xdebug is used for debugging, the session still exists.

If PHP's session_start () function is used, a new session is generated, which is irrelevant to the cookie. The cookie debugging method is firebug or chrome dev tool.

Take my website as an example http://justjavac.com/

Http://www.php.net/manual/zh/function.setcookie.php

Set the validity period to a previous time.

setcookie ($auth_cookie_name, "", time() - 3600);

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.