The code is as follows
代码如下 |
复制代码 |
setcookie(name, value, expire, path, domain);
function w_cookie($n, $c, $e = 0,$isdes=1)
{
if($isdes==1){$c=endes($c,deskey);}
$exp = time() + 3600 * 24 * 30;
if($e == 0)
{
setcookie($n, $c, $exp,"/");
}
else
{
setcookie($n, $c,0,"/");
}
}
|
|
Copy code
|
setcookie(name, value, expire, path, domain);
function w_cookie($n, $c, $e = 0,$isdes=1)
{
if($isdes==1){$c=endes($c,deskey);}
$exp = time() + 3600 * 24 * 30;
代码如下 |
复制代码 |
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);
}
}
//调用方法
cookie("website","安卓主题","./","www.hzhuti.com");
//
|
If($e == 0)
{
setcookie($n, $c, $exp,"/");
}
else
代码如下 |
复制代码 |
$time = time() + 300; //5分钟过期
$code = md5($string . $time . $salt);
setcookie('check_time', $time);
setcookie('code', $code);
//验证部分
$TIME = time();
if($check_time < $TIME)//如果服务器时间比验证时间大,算过期
//expire过期
if(md5($string . $check_time . $salt) !== $code)
|
{
setcookie($n, $c,0,"/");
} |
}