How to make cookies in PHP take effect without refreshing_PHP Tutorial

WBOY
Release: 2016-07-21 15:20:43
Original
956 people have browsed it

However, this mechanism will always bring us some problems. For example, some time ago, I had to set up an ad display function on my site, which required the use of COOKIE. The main purpose was to increase the conversion rate of advertising. , but if the refresh takes effect, it will be more troublesome, so I used this method, which is easy to use.
The following is the code:

Copy the code The code is as follows:

function cookie($var, $value='' , $time=0, $path='', $domain=''){
$_COOKIE[$var] = $value;
if(is_array($value)){
foreach($ value as $k=>$v){
setcookie($var.'['.$k.']', $v, $time, $path, $domain, $s);
}
}else{
setcookie($var, $value, $time, $path, $domain, $s);
}
}

//Call method

cookie("website","WEB Development Notes","./","www.jb51.net");
//
echo $_COOKIE["website"];//output WEB Development Notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325049.htmlTechArticleHowever, this mechanism will always bring us this or that problem. For example, some time ago, my To set up an ad display function on the site, you need to use COOKIE. The main purpose is...
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!