Home > php教程 > php手册 > body text

php中用数组的方法设置cookies

WBOY
Release: 2016-06-06 20:36:39
Original
930 people have browsed it

php中用数组的方法设置cookies,需要的朋友可以参考下。

代码如下:
function set_cronology($name,$value,$duration=7){
$duration=time()+(3600*24*$duration);
$max_stored_values=5;
if(isset($_COOKIE[$name])){
foreach($_COOKIE[$name] as $prop_crono=>$val_crono){
if($val_crono==$value)
return;
}
if($prop_crono setcookie($name.'['.($prop_crono+1).']',$value,$duration);
else{
array_shift($_COOKIE[$name]);
setcookie("$name[$max_stored_values]",$value,$duration);
}
}else
setcookie($name.'[0]',$value,$duration);
return;
}
?>
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 Recommendations
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!