zoukankan      html  css  js  c++  java
  • 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一直有效的原因

  • 相关阅读:
    YUV图片旋转
    mac http&git代理配置
    iOS 如何保持线程一直在运转
    iOS 后台录音Tweak实现参考--stackoverflow
    NSTimer的精确度
    svn递归添加目录下面所有文件
    利用instruments工具查看其它app的性能
    iOS符号表手工还原
    Hbase的安装测试工作
    Hadoop集群中pig工具的安装过程记录
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199769.html
Copyright © 2011-2022 走看看