- /**
- * 不刷新 cookie及时生效
- * site http://bbs.it-home.org
- */
- cookie("mycookie","cookievalue",time()+60);
- var_dump($_COOKIE["mycookie"]);
-
- //PHP COOKIE设置函数立即生效,支持数组
- 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, 0);
- }
- }else{
- setcookie($var, $value, $time, $path, $domain, 0);
- }
- }
- ?>
-
有兴趣的朋友,可以了解下:php5中Cookie与Session用法 。 |