Reputation: 177
I am using Code-igniter framework for Several web applications and running that application's from one Server. I am facing one issue that whenever user will Logout from one application, automatically user will get logout from other applications on that server.
Below is the code for Maintaining Session :
$session_data = array(
'user_id' => $userdetails[0]->user_id,
'user_type' => $userdetails[0]->user_type,
'user_name' => $userdetails[0]->user_name,
'logged_in' => TRUE
);
$this->session->set_userdata($session_data);
And This is Code for Destroying Session :
$session_data = array(
'user_id' => '',
'user_type' => '',
'user_name' => '',
'logged_in' => FALSE
);
$this->session->unset_userdata($session_data);
What Changes i have to done either in Controller or in Config file to Get rid of this Issue?
Upvotes: 0
Views: 103
Reputation: 510
Go to your config folder and change following settings for every project. Give them a unique name
$config['sess_cookie_name'] = 'ci_session';
ci_session is default name
Upvotes: 1
Reputation: 247
For this use this method for session create and destroy,
$logindata['user_id'] = $userdetails[0]->user_id;
$logindata['user_type'] = $userdetails[0]->user_type;
$logindata['user_name'] = $userdetails[0]->user_name;//add your session data here
$this->session->set_userdata('session_name',$logindata); // use session name different for different project
And for destroy session use this,
$this->session->unset_userdata('session_name'); //use which session name you want to destroy
Upvotes: 0