Reputation: 651
I'm trying to retrieve session data and use it inside codeigniter, I have a php page having this code:
session_start();
$_SESSION['views']=1;
and when i want to retrive it in codeigniter page and it's in another folder using :
echo $_SESSION['views'];
or
echo $this->session->userdata('views');
Result is undefined. i'm using codeigniter 2 and also using this class.
https://bitbucket.org/Molchy/ndb-session-class-for-codeigniter/wiki/Home
and thanks.
Upvotes: 0
Views: 415
Reputation: 11984
I think you have to use this in Codeignitor
To set
$this->session->userdata('views',1);
To get
echo $this->session->userdata('views');
If you are using php session then you do the following
To set
session_start();
$_SESSION['views']=1;
To get
echo $_SESSION['views'];
Upvotes: 0
Reputation: 37701
PHP's sessions ($_SESSION) and CI's sessions are not the same.
To set data to CI's session, simply do: $this->session->set_userdata('views', 1);
It's all very nicely documented: http://ellislab.com/codeigniter%20/user-guide/libraries/sessions.html
Upvotes: 1