The custom session processing method fails to load the verification code.

Source: Internet
Author: User
A very crazy problem. It was not completed in the afternoon. Please advise that the verification code exists in the SESSION and can be written into the database, but cannot be loaded in the browser. The controller where the verification code output method is located is inherited from the BackplatformController...

A very crazy problem. I haven't finished it in the afternoon. Please advise me.

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

The Controller of the verification code output method inherits from the BackplatformController controller,

Call the session class in the construction method of BackplatformController

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 sess_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 (); // If yes, update $ 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 an expired session $ SQL = "delete from it_session where expire <$ last "; return $ this-> db-> myquery ($ SQL );}}

Below is the verification code stored in the session

Reply content:

A very crazy problem. I haven't finished it in the afternoon. Please advise me.

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

The Controller of the verification code output method inherits from the BackplatformController controller,

Call the session class in the construction method of BackplatformController

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 sess_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 (); // If yes, update $ 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 an expired session $ SQL = "delete from it_session where expire <$ last "; return $ this-> db-> myquery ($ SQL );}}

Below is the verification code stored in the session

The 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.