Usually, you need to refresh the browser to make cookies appear in PHP. How can you make cookies take effect in a timely manner? Here is a method to make cookies take effect in a timely manner. It is very practical. The code is as follows:
Copy code The code is as follows:
/**
* Set cookie
* @param string $name key name
* @param mixed $value value
* @param int $expire expiration time, the default is one day
*/
public final function setCookie($name , $value, $expire = null){
//Cookie value is empty, exit
if(empty($value)) return;
//Expiration time
if(empty($expire) )) $expire = time() + 86400;
$_COOKIE[$name] = $value;
//Determine whether value is an array
if(is_array($value)){
foreach ($value as $k => $v){
> }
}else{
} setcookie($name, $value, $expire);
}
}
http://www.bkjia.com/PHPjc/825218.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825218.htmlTechArticleUsually, you need to swipe the browser to display cookies in PHP. How can you make cookies take effect in time? Let’s share one A very practical way to make cookies take effect in a timely manner, the code is as follows: Copy the code...