First set in index.php to:
<?php
Define (' App_debug ', true);//set to debug mode
Require '. /thinkphp/thinkphp.php ';//Set the entry file
Ini_set ("Session.save_handler", "user");//Set PHP session by user-defined
Set in config.php to:
<?php
return Array (//' configuration item ' = ' config value ')
Add a database configuration letter
' Show_page_trace ' =>true,
' Db_type ' = ' mysql ',//database type
' db_host ' = ' localhost ',//server address
' Db_name ' = ' thinkphp ',//database name
' Db_user ' = ' Your user name ',//user name
' Db_pwd ' = ' Your password ',//password
' Db_port ' = 3306,//Port
' Db_prefix ' = ' think_ ',//database table prefix suffix
' Session_options ' =>array (
' Type ' = ' db ',//session with database save
' Expire ' =>1440,//session expiration time, if not set is the default value in PHP.ini
),
' session_table ' = ' think_session ',//must be set to this, if you do not add a prefix to find the data table, this need to note
);
?>
The database settings use the DDL in SessionDb.class.php, but the Engine=myisam DEFAULT Charset=utf8 is added later
CREATE TABLE Think_session (
session_id varchar (255) is not NULL,
Session_expire Int (one) is not NULL,
Session_data Blob,
UNIQUE KEY ' session_id ' (' session_id ')
) Engine=myisam DEFAULT Charset=utf8;
Now visit your index.php and find the Think_session table in phpMyAdmin, we will be pleasantly surprised to find a lot of data.
This problem is done. Do not set the other, SessionDb.class.php will automatically load.
So the thinkphp call
Session (' Session_name ', ' Session_value ')
Article reprinted from The Home Management house: http://www.bitscn.com/pdb/php/201408/305909.html
thinkphp implementation of the session to the MySQL method