My localhost is XAMPP. The two projects are basically the same code, at least the login module. The projects are built with Codeigniter.
My problem is, for example, if I logged in on Project A, then I found I’m automatically logged in on Project B, too.
The two projects does not use the same database, but their login code is the same. When the user visit the page, I will check the variable $this->session->isLoggedIn
first, if so, I will redirect the page to the user page. I do find that they use the same session id. Is this a common issue on the localhost, since they share the same domain, or I made a mistake?
Advertisement
Answer
while set session
you need to differentiate
the session
Based on project
for your identification like this
$this->session->set_userdata('project_A_username', 'usernamehere');
and
$this->session->set_userdata('project_B_username', 'usernamehere');
.
php session is common for all your project . so you have to differentiate.
OP comments : If so, this will not happen in the live environment, since they are not under the same domain?
yes it will not happen .since they are in different domain .