Session Codeigniter PHP

Asked

Viewed 120 times

1

I have two different systems. Both created with codeigniter.

The problem is this: Do logon in the 1 system and I use normally, then I open the 2 system, and then it occurs that the Session of that new system overwrites the old one. So when I go to save the id user saved on session in the db of the first system, it inserts the id logged in user of the new system.

Any hints or suggestions?

2 answers

2


Just change the

$config['sess_cookie_name'] = "ci_session";

it comes as default. then switch to one of your preference that is not equal to the other system.

OBS:

The browser saves the session as cookie, then when the systems have the same name as session He ends up using what was started after. then when the names are different he creates another cookie of a new session instead of overwriting the old.

  • Mark the answer so as not to leave the question open...

1

This is related to Session Preferences. You have to tell the application in what context it should manage/read session data. The documentation says the configuration options cookie_domain and cookie_path influence the behaviour of the session, as shown in link indicated above:

In addition to the values above, the cookie and Native drivers apply the following Configuration values Shared by the Input and Security classes:

Tell the session library which domain or the path for which the current session applies. If you leave this blank in the application configuration (application/config/config.php), the browser will understand that the session is valid for all contexts, and will use it in this way.

To avoid this, change application/config/config.php to the right domain:

$config['cookie_domain']    = 'aplicacao.com.br';

Or for the path correct:

$config['cookie_path']      = '/aplicacao';
  • thanks for the answer! but in my case it did not resolve like this. i read the documentation and saw that just change the default $config['sess_cookie_name']

Browser other questions tagged

You are not signed in. Login or sign up in order to post.