• php session 管理


    function do_login(){
    		//获取用户名和密码信息,和数据库中比对
    		 echo 111111111;
    		dump($_POST);
    		dump($_SESSION);
    		echo 222222222;
    		$username=$_POST['username'];
    		$password=$_POST['password'];
    		$code=$_POST['code'];
    		#$this->display();
    		if($_SESSION['verify']!==md5($code)){
    			$this->error('验证码错误');
    		}
    		
    
    111111111
    
    array (size=3)
    
    
    
      'username' => string '3131' (length=4)
      'password' => string '313' (length=3)
      'code' => string '1936' (length=4)
    
    array (size=3)
      'verify' => string '11108a3dbfe4636cb40b84b803b2fff6' (length=32)
      'username' => string 'admin' (length=5)
      'authority' => string '1' (length=1)
    
    222222222
    
    
    1936 MD5 加密后的值为:
    
    mysql> select md5(1936) from user limit 1;
    +----------------------------------+
    | md5(1936)                        |
    +----------------------------------+
    | 11108a3dbfe4636cb40b84b803b2fff6 |
    +----------------------------------+
    1 row in set (0.00 sec)
    
    
    验证码判断:
    
    if($_SESSION['verify']!==md5($code)){
    			$this->error('验证码错误');
    		}
    		
    
    		
    验证码错误:
    111111111
    
    array (size=3)
      'username' => string '3131' (length=4)
      'password' => string '4124124' (length=7)
      'code' => string '2059' (length=4)
    
    array (size=3)
      'verify' => string 'd3c95acb3f4a091abb1fdc056dc68c1c' (length=32)
      'username' => string 'admin' (length=5)
      'authority' => string '1' (length=1)
    
    222222222
    
    
    
    mysql> select md5(2059) from user limit 1;
    +----------------------------------+
    | md5(2059)                        |
    +----------------------------------+
    | 2eace51d8f796d04991c831a07059758 |
    +----------------------------------+
    1 row in set (0.00 sec)
    
    
    
    
    		
    		
    		
    
    111111111
    
    array (size=3)
      'username' => string '331342453' (length=9)
      'password' => string '535353' (length=6)
      'code' => string '434224' (length=6)
    
    array (size=3)
      'verify' => string '7cce53cf90577442771720a370c3c723' (length=32)
      'username' => string 'admin' (length=5)
      'authority' => string '1' (length=1)
    
    222222222
    
    mysql> select md5(434224) from user limit 1;
    +----------------------------------+
    | md5(434224)                      |
    +----------------------------------+
    | 80bf385de86b2e02292a10caceed2c4b |
    +----------------------------------+
    1 row in set (0.00 sec)
    
    
    
    
    111111111
    
    array (size=3)
      'username' => string '3131' (length=4)
      'password' => string '13131' (length=5)
      'code' => string '9424124' (length=7)
    
    array (size=1)
      'verify' => string 'd04eb5de4d99080be674f159197a514a' (length=32)
    
    222222222
    
    
    之前session 一直有'username' => string 'admin'  和  'authority' => string '1'
    
    因为session一直有效的原因

  • 相关阅读:
    Jupyter notbook快捷键
    tensorboard 的使用
    numpy——数组存取
    numpy——使用函数创建(2)
    numpy——使用array创建(1)
    python列表与元组
    python 格式化输出
    全排列递归算法
    【机器学习】ex1-线性回归
    【Web安全】三、SQL盲注
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199770.html
Copyright © 2020-2023  润新知