1. 程式人生 > >PHP 讀取session和往session寫內容

PHP 讀取session和往session寫內容


    請求資訊 : 2017-05-11 19:36:04 HTTP/1.1 GET : /DEVOPS/index.php/Main/index
    執行時間 : 0.0297s ( Load:0.0048s Init:0.0110s Exec:0.0004s Template:0.0134s )
    記憶體開銷 : 2,012.68 kb
    查詢資訊 : 0 queries 0 writes
    檔案載入 : 33
    快取資訊 : 0 gets 0 writes
    配置載入 : 138
    會話資訊 : SESSION_ID=lsnqn8pks7hl9qet2she86pke5

node2:/var/www/html/DEVOPS/Home/Lib/Action#vim IndexAction.class.php

<?php
 class IndexAction extends Action {
         function index(){
                 $this->display();
         }

        function do_login(){
                //獲取使用者名稱和密碼資訊,和資料庫中比對
                 echo 111111111;
                 dump($_POST);
                 echo 222222222;
                 dump($_SESSION);
                 echo 33333333;

                $username=$_POST['username'];
                $password=$_POST['password'];
                $code=$_POST['code'];
                 echo md5($code);
	

	
	111111111

array(3) {
  ["username"] => string(5) "admin"
  ["password"] => string(5) "admin"
  ["code"] => string(4) "5653"
}

222222222

array(3) {
  ["verify"] => string(32) "d7e4cdde82a894b8f633e6d61a01ef15"
  ["username"] => string(5) "admin"
  ["authority"] => string(1) "1"
}

33333333d7e4cdde82a894b8f633e6d61a01ef15

往SESSION寫東西:

<?php
 class IndexAction extends Action {
         function index(){
                 $this->display();
         }

        function do_login(){
                //獲取使用者名稱和密碼資訊,和資料庫中比對
                 $_SESSION['aaa']='ssada1';
                 echo 111111111;
                 dump($_POST);
                 echo 222222222;
                 dump($_SESSION);
                 echo 33333333;



111111111

array(3) {
  ["username"] => string(5) "admin"
  ["password"] => string(5) "admin"
  ["code"] => string(4) "7334"
}

222222222

array(4) {
  ["verify"] => string(32) "7fcb0a2c0f0f41d9f4454ac2d8ed7ad6"
  ["username"] => string(5) "admin"
  ["authority"] => string(1) "1"
  ["aaa"] => string(6) "ssada1"
}

333333337fcb0a2c0f0f41d9f4454ac2d8ed7ad6