Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using codeigniter 2.1.0.

I am trying to do a register/login function using the session library in the codeigniter.

The register/login with the session library worked fine for localhost, but when I put it live and tried it, the session does not work.

My controller login works this way. I check the credentials, once ok I set my session data and redirect to another page.

$user_data = array(
                   'username'       => $result->user_name,
                   'email'          => $result->user_email,
                   'userid'         => $result->user_id,
                   'role'           => $result->user_role,
                   'login_state'    => TRUE,
                   'lastlogin'      => time(),
               );

$this->session->set_userdata($user_data);           
print_r( $this->session->all_userdata());            
redirect(base_url('dashboard'));

at this point here when I print all my session data, they do print out. But at the dashboard controller side, when i attempt to print the session data out, they were not there anymore.

Any idea why? Thanks in advance for the help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
809 views
Welcome To Ask or Share your Answers For Others

1 Answer

if you are working in CI 3.x and just upgraded your server php version to php 7.x

Go to system/libraries/Session/session.php at Line no 281 and replace ini_set('session.name', $params['cookie_name']); by ini_set('session.id', $params['cookie_name']);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...