PHP记住密码+

/**
* 记住密码/清空密码
*
* @param $account 登录的账号
* @param $pwd 登录的密码
* @param $name 缓存名称
* @param t y p e 1 记 住 0 清 空 ∗ / p u b l i c f u n c t i o n S e t P a s s w o r d ( type 1记住 0清空 */ public function SetPassword( type10/publicfunctionSetPassword(account, $pwd , $name, KaTeX parse error: Expected '}', got 'EOF' at end of input: …0){ if(type == 1) {
$data = array(
‘phone’ => $account,
‘pwd’ => $pwd
);
k e y = b a s e 6 4 e n c o d e ( j s o n e n c o d e ( key = base64_encode(json_encode( key=base64encode(jsonencode(data));
setcookie($name, KaTeX parse error: Expected 'EOF', got '}' at position 58: …true); }̲else{ …name,’’ , time() - 3600 * 24 * 30, ‘/’, ‘’, ‘’, true);
}
}

/**
* 得到保存的密码
* @param $name
* @return mixed
*/
public function GetPassword($name){
    $info = array();
    if(!isset($_COOKIE[$name])){
        $data['errorCode'] = 1;
    }else{
        if($_COOKIE[$name] == ''){
            $data['errorCode'] = 1;
        }else{
            $key = json_decode(base64_decode($_COOKIE[$name], true),true);
            if(!is_array($key)){
                $data['errorCode'] = 1;
            }else{
                $data['errorCode'] = 0;
                $info['phone'] = $key['phone'];
                $info['pwd'] = $key['pwd'];
                $info['type'] = 1;
            }
        }
    }
    if($data['errorCode'] == 1){
        $info['phone'] = '';
        $info['pwd'] = '';
        $info['type'] = 0;
    }
    return $info;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值