简体   繁体   中英

Integrating normal php session in codeigniter

I have been experiencing session in codeigniter but I have some failure since sometime I need to register session without using controller. For instance When a facebook user login in my app using FACEBOOK SDK this plugins use normal php session, so when I try to get them in codeigniter controller I fail; In other part when I register a session in a controller I will need to call the same session in other controllers or register base controller. Killing codeIgniter session does not remove SDK session and cookies. So How can I use normal session in CodeIgniter so that I don't loose SDK functionality. Thanks.

A replacement of codeigniter's sessions is already available, It's called Native Sessions class, You just drop the files in their places & everything should work as expected.

https://github.com/appleboy/CodeIgniter-Native-Session

The facebook wrapper was written as it is for this very reason. Managing data used with or by the base class is done in this wrapper.

After assigning the CI superglobal to the facebook class in the constructor

$this->ci =& get_instance();

Replace all instances of

$_SESSION

With and the relevant information as it would have gone previously into $_SESSION

//Add data to the session
$this->ci->session->set_userdata();

//Remove data from the session
$this->ci->session->unset_userdata();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM