开发者

save session in database by CodeIgniter

I want to save session in database.in CodeIgniter user guide , make an example to store some data in database.

CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text DEFAULT '' NOT NULL,
PRIMARY KEY (session_id)
);

Now I want to store an ext开发者_JS百科ra data by session in datbase,for example request_token value.

$this->session->set_userdata('request_token','test');

How should I do it by session?


Go to your config.php under application folder and set use session database option to true. Import the sql structure like you have there and use sessions like you have. It will store the session variable in db. You might want to enable session encryption as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜