PHPCOOKIE timely effective method introduction. Generally, php requires a browser click to generate a cookie. how can we make the cookie take effect in a timely manner? here is a method to make the cookie take effect in a timely manner. the code is as follows: copying code usually requires a browser click in php to generate a cookie. how can we make the cookie take effect in a timely manner? here is a practical method to make the cookie take effect in a timely manner,
The code is as follows:
The code is as follows:
/**
* Set cookie
* @ Param string $ name Key name
* @ Param mixed $ value
* @ Param int $ expire expiration time. the default value is one day.
*/
Public final function setCookie ($ name, $ value, $ expire = null ){
// If the cookie value is null, exit
If (empty ($ value) return;
// Expiration time
If (empty ($ expire) $ expire = time () + 86400;
$ _ COOKIE [$ name] = $ value;
// Determine whether the value is an array.
If (is_array ($ value )){
Foreach ($ value as $ k => $ v ){
If (empty ($ v) continue;
Setcookie ($ name. "[$ k]", $ v, $ expire );
}
} Else {
Setcookie ($ name, $ value, $ expire );
}
}
The code is as follows :...