Home  >  Article  >  Backend Development  >  Introduction to how to make PHP COOKIE effective in a timely manner_PHP Tutorial

Introduction to how to make PHP COOKIE effective in a timely manner_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:04735browse

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

truehttp: //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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn