萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php cookie實例

php cookie實例

php cookie實例
這裡是用php cookie來設置用戶登陸的時間與過期時間代碼哦

function loginCookie($uid,$name,$group,$ip,$time)
{
 global $site_domain,$login_key;
 
 $domain = (substr($site_domain,0,4) == "www.") ? substr($site_domain,3) : ".".$site_domain;

 $secure = Xxtea::encrypt($uid."|".$name."|".$group."|".$ip,$login_key);

 setcookie("userId",$uid,$time+86400,"/",$domain);

 setcookie("userName",$name,$time+86400,"/",$domain);

 setcookie("userGroup",$group,$time+86400,"/",$domain);
   
 setcookie("userSecure",$secure,$time+86400,"/",$domain);
}

copyright © 萬盛學電腦網 all rights reserved