http://blog.csdn.net/zhan198271/archive/2010/10/06/5923839.aspx
http://www.cnblogs.com/Anima0My/archive/2008/04/05/1136854.html
function PutCookie($key,$value,$kptime=0,$pa="/")
{
global $cfg_cookie_encode;
setcookie($key,$value,time()+$kptime,$pa);
setcookie($key.'__ckMd5',substr(md5($cfg_cookie_encode.$value),0,16),time()+$kptime,$pa);
}
function DropCookie($key)
{
setcookie($key,'',time()-360000,"/");
setcookie($key.'__ckMd5','',time()-360000,"/");
}
function GetCookie($key)
{
global $cfg_cookie_encode;
if( !isset($_COOKIE[$key]) || !isset($_COOKIE[$key.'__ckMd5']) )
{
return '';
}
else
{
if($_COOKIE[$key.'__ckMd5']!=substr(md5($cfg_cookie_encode.$_COOKIE[$key]),0,16))
{
return '';
}
else
{
return $_COOKIE[$key];
}
}
}
cookie加密密码DwGBc2933O,
function GetCookie($key)
{
global $cfg_cookie_encode;
if( !isset($_COOKIE[$key]) || !isset($_COOKIE[$key.'__ckMd5']) )
{
return '';
}
else
{
if($_COOKIE[$key.'__ckMd5']!=substr(md5($cfg_cookie_encode.$_COOKIE[$key]),0,16))
{
return '';
}
else
{
return $_COOKIE[$key];
}
}
setcookie($key,$value,time()+$kptime,$pa);
setcookie($key.'__ckMd5',substr(md5($cfg_cookie_encode.$value),0,16),time()+$kptime,$pa);
PutCookie('DedeUserID',$uid,$this->M_KeepTime);
PutCookie('DedeLoginTime',$this->M_LoginTime,$this->M_KeepTime);
}
PutCookie('DedeUserID',$uid,$this->M_KeepTime);
PutCookie('DedeLoginTime',$this->M_LoginTime,$this->M_KeepTime);
setcookie($key,$value,time()+$kptime,$pa);
setcookie($key.'__ckMd5',substr(md5($cfg_cookie_encode.$value),0,16),time()+$kptime,$pa);
MD5 是不可逆加密。