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

WBOY
Release: 2016-07-13 10:25:04
Original
737 people have browsed it

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!