gox
gox

Reputation: 51

Codeigniter session won't work

I've been watching this tuts from yt how to build login system with Codeigniter

Here is link from tutorial

when guy from video put this code to get user data

<?php print_r ($this->session->all_userdata ());?>

he gets array with all data like in this video. I receive array like this

Array( [__ci_last_regenerate] => 1467913653)

So when try to login it always redirect me to restricted area even when email and password are good, and all should work.

Is it problem because I use Codeigniter 3, in video is CI 2?

Upvotes: 2

Views: 1152

Answers (2)

Alaa M. Tekleh
Alaa M. Tekleh

Reputation: 7966

make sure that session library is loaded you can auto load it from config/autoload.php as follows

$config['libraries'] = array('session');

or load it in controller constructor as follows

$this->load->library('session');

and then you can get session data by call this method

$this->session->userdata();

I hope my answer would be useful

Upvotes: 5

Florin
Florin

Reputation: 6179

If you want to retrieve all of the existing userdata, you can simply omit the item key (magic getter only works for properties):

$_SESSION

// or:

$this->session->userdata();

Here is the documentation

Upvotes: 0

Related Questions