Idhos
Idhos

Reputation: 23

Session automatically destroy in codeigniter

Salam. I have problem about codeIgniter. I using codeIgniter version 2.2.0, I create 2 projects with them. The problem is, when i open both projects at the same browser. and if i have login at project 1, and then i go to the project 2 (not have login at project 2) and doing refresh (F5) on project 2, then i coming back to project 1, the project 1 get logged out. why this happen?

Please help. what's wrong? Is that about my syntax, or about my codeIgniter version, or about my xampp version? I use xampp version 1.7.7. Thanks.

Upvotes: 2

Views: 5654

Answers (2)

smehsoud
smehsoud

Reputation: 312

if you are using local host than use same system folder for all projects. If their is different version CI in your local host than it will create the issue. I fix my issue with replacing system folder with the already exists in previous project. You can check ci version by echo CI_VERSION;

Upvotes: 0

AceKYD
AceKYD

Reputation: 1140

Its not your syntax nor browser or xampp version... When making new installations of CodeIgniter, there are certain variables that have the same name across installations by default... one of which is the sessions variable... So even if you have multiple installations of codeIgniter, by default, they would all be using the same session name which is why you are having that login or logout problem when you switch projects...

The solution now is to update the session name for each of your installations so they can be unique with no risk of corresponding with another installation...

Go to your application/config/config.php file and search for this line $config['sess_cookie_name'] = 'ci_session'; Change the value of each installation to something unique to your project e.g $config['sess_cookie_name'] = 'project1_session';

Thats all.

Upvotes: 3

Related Questions