让PHP COOKIE及时生效,不用刷新就可以使用

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);
	}
}

你可能感兴趣的:(PHP,function,domain,Path)