user1577291
user1577291

Reputation: 365

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.

Upvotes: 0

Views: 2524

Answers (2)

David Barker
David Barker

Reputation: 14620

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();

Upvotes: 1

Frank
Frank

Reputation: 534

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

Upvotes: 2

Related Questions