PHP Settings and get cookies
Create a cookie
Setcookie (' MyCookie ', ' value ', Time () +86400);//Parameter 3 cookie expiration
function prototypes: int Setcookie (string name,string value,int expire,string path,string domain,int Secure)
Echo ($mycookie);
Echo ($HTTP _cookie_vars[' MyCookie ');
Echo ($_cookie[' MyCookie ');
Delete Cookies
1) Setcookie (' name '); Call Setcookie () with the name parameter only;
2) Setcookie (' MyCookie ', ', ', Time ()-1); Make the expiry date () or Duration ()-1;
Ways to get the cookie expiration time
$expire = time () + 86400; Set the 24-hour validity period
Setcookie ("Var_name", "Var_value", $expire); Set a cookie named Var_name, and establish a validity period
Setcookie ("Var_name_expire", $expire, $expire); Then set the expiration time to a cookie so that you can know the expiration time of the Var_name
Note:
When a cookie is sent, the value of the cookie is automatically URL-encoded. The URL is decoded when it is received.
If you don't need this, you can use Setrawcookie () instead.
Operation of Cookies in PHP