The custom session processing mode causes the code to fail to load.

Source: Internet
Author: User

A very crazy problem, engaged in an afternoon did not fix, please master advice

The problem is that the verification code exists in the session and can be written into the database, but it cannot be loaded in the browser.

The controller that the verification code output method resides in inherits from the Backplatformcontroller controller,

The session class is called in the Backplatformcontroller constructor method.

The following is a custom session class


  db = Mysqldb::getinstance ($GLOBALS [' config '] [' database ']);    }/** * Close * @return BOOL */Public Function sess_close () {return true; }/** * @param $sess _id * @return String */Public Function Sess_read ($sess _id) {$sql = "select ses        S_data from it_session where sess_id= ' $sess _id ' ";        if ($row = $this->db->fetchrow ($sql)) {return $row [' Sess_data '];        }else{return ';        }}/** * @param $sess _id * @param $sess _data */Public Function sess_write ($sess _id, $sess _data) {        $expire =time (); Presence is updated $sql = "INSERT into it_session values (' $sess _id ', ' $sess _data ', ' $expire ') on duplicate key update Sess_data= ' $        Sess_data ', expire= ' $expire ' ";        if ($result = $this->db->myquery ($sql)) {return true; }}/** * @param $sess _id */Public Function Sess_destroy ($sess _id) {$sql = "Delete from it_session where sess_id= ' $sess _id '";    $result = $this->db->myquery ($sql);        }/** * @param $ttl * @return Mixed * * Public function sess_gc ($ttl) {$now = time ();        $last = $now-$ttl;        Delete expired Session $sql = "Delete from it_session where expire < $last";    return $this->db->myquery ($sql); }}

Here is the verification code stored in session

Reply content:

A very crazy problem, engaged in an afternoon did not fix, please master advice

The problem is that the verification code exists in the session and can be written into the database, but it cannot be loaded in the browser.

The controller that the verification code output method resides in inherits from the Backplatformcontroller controller,

The session class is called in the Backplatformcontroller constructor method.

The following is a custom session class


  db = Mysqldb::getinstance ($GLOBALS [' config '] [' database ']);    }/** * Close * @return BOOL */Public Function sess_close () {return true; }/** * @param $sess _id * @return String */Public Function Sess_read ($sess _id) {$sql = "select ses        S_data from it_session where sess_id= ' $sess _id ' ";        if ($row = $this->db->fetchrow ($sql)) {return $row [' Sess_data '];        }else{return ';        }}/** * @param $sess _id * @param $sess _data */Public Function sess_write ($sess _id, $sess _data) {        $expire =time (); Presence is updated $sql = "INSERT into it_session values (' $sess _id ', ' $sess _data ', ' $expire ') on duplicate key update Sess_data= ' $        Sess_data ', expire= ' $expire ' ";        if ($result = $this->db->myquery ($sql)) {return true; }}/** * @param $sess _id */Public Function Sess_destroy ($sess _id) {$sql = "Delete from it_session where sess_id= ' $sess _id '";    $result = $this->db->myquery ($sql);        }/** * @param $ttl * @return Mixed * * Public function sess_gc ($ttl) {$now = time ();        $last = $now-$ttl;        Delete expired Session $sql = "Delete from it_session where expire < $last";    return $this->db->myquery ($sql); }}

Here is the verification code stored in session

It's done, OB cache is not cleared

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.