Create:
Using Setcookie (String $name [, String $value = "" [, int $expire = 0 [, String $path = "" [, String $domain = "" [, BOOL $se Cure = False [, bool $httponly = false]]] []]]) function creation,
| Parameters |
Describe |
| Name |
Required, specify cookie name |
| Value |
Required, specify the value of the cookie |
| Expire |
Optional, to specify the validity period of the cookie |
| Path |
Optional, specify cookie server path |
| Domain |
Optional, specify the role of the cookie domain name |
| Secure |
Optional, specify whether to transfer cookies over HTTPS |
| HttpOnly |
Optional to specify whether cookies can only be accessed via the HTTP protocol (PHP5.2.0 join) |
When expire is not specified, the cookie is automatically cleared when the current session ends (browser close).
Setcookie ("TestCookie", "This was Test"); Setcookie ("TestCookie", "This is Test", Time () +3600); /* Valid for 1 hours * *
Setcookie after use, the Set-cookie information can be found in the HTTP request header.
Clear:
1. To delete a cookie, you need to ensure that it expires before triggering the browser's removal mechanism.
Use the Setcookie function to set the time to expire.
Setcookie ("TestCookie", "", Time ()-3600);
2. Set a null value for the cookie. ( This method is not recommended , the manual does not indicate this method, but in Linux under the EXT/STANDARD/HEAD.C section of the PHP source code, Php_setcookie () mentioned)
Setcookie ("TestCookie", "" "); Setcookie (" TestCookie ", NULL);
Php--cookie