支付宝赞助帐号:service@kuitao8.com 

thinkphp用户名记住密码的方法

Created2014-12-25   Views 10602    Author 懒人程序
public function login()  // 用户登录页面
    {
        if($this->isPost())
        {
            if(!$this->_post('account'))
            {
                $this->error('用户名不能为空');
                
                exit;
            }
            
            $data["post"]=array
            (
                'name'=>trim($this->_post('account')),
            
                'password'=>trim($this->_post('password'))           
            );
         
            $info=D("User")->getinfo('admin_user','login',$data);
 
            if($info["status"])
            {
                $this->cache_user($info['user']);
                
                R('Logs/loginlogs',array($info['user']));
       
                $remember=$this->_post('remember');
 
                if($remember==1)
                {
                    cookie('remember_password',trim($this->_post('password')),3600*24*30); // 指定密码保存一个月
                    
                    cookie('remember_account',trim($this->_post('account')),3600*24*30); // 指定密码保存一个月
                }
                
                redirect(U('Index/index'));//如果通过认证跳转到首页
            }
            else
            {
                $this->error($info["error_log"]);
            }
        }
        else
        {
            $value2 = cookie('remember_password');
            
            $value3 = cookie('remember_account');
            
             if($value2&&$value3)
             {
                $this->assign('pass',$value2);
                
                $this->assign('account',$value3);
             }
             
            $this->display('admin_login');
        }  
    }
上一篇: PHP CURL函数库
下一篇: dedecms友情链接flink的调用方法
支持键盘 ← →

邮件订阅

订阅我们的精彩内容