The cookie name is a variable with the same name. For example, if the sent cookie is named "name", a variable named $ user is automatically created, containing the cookie value.
The cookie must be assigned a value before any other output is sent.
If the call succeeds, the function returns true; otherwise, the function returns false.
Syntax
Setcookie (name, value, expire, path, domain, secure)
*/
$ Cookieinfo = session_get_cookie_params (); // Obtain cookie information
If (empty ($ cookieinfo ['domain ']) & (empty ($ cookieinfo ['Secure']) // check whether the result is null
{
Setcookie (session_name (), '', time ()-3600, $ cookieinfo ['path']); // Set cookie
}
Elseif (empty ($ cookieinfo ['Secure ']) // check whether the option is null
{
Setcookie (session_name (), '', time ()-3600, $ cookieinfo ['path'], $ cookieinfo ['domain']); // Set cookie
}
Else
{
Setcookie (session_name (), '', time ()-3600, $ cookieinfo ['path'], $ cookieinfo ['domain'], $ cookieinfo ['Secure ']); // Set cookie
}
// Session_destroy (); // cancel the session
Print_r ($ _ session );
Print_r ($ _ cookie );
// You can use session_set_cookie_params to set the lifetime and path.
Session_set_cookie_params (0, '/yourpath/'); // Set the cookie survival time and path
/*
Note: You can use $ http_cookie_vars ["user"] or $ _ cookie ["user"] to access the cookie value named "user.
Note: When sending a cookie, the cookie value is automatically url encoded. Url decoding is performed when receiving the message. If you do not need this, you can use setrawcookie () instead.
*/