Your problem may be facing cookie sharing.
Let’s assume that the URL
of produção
your see p.x: prod.url.com
and that of homologação
be it homo.url.com
. OK?
When setting a cookie, it is set to .url.com
that is, it will remain persistent both in prod.url.com
or homo.url.com
who are sub-dominios
of url.com
. Accompanied?
PHP gives you the possibility to set the cookie for domain:
setcookie('YourCookieName', 'Some Values', time() + 3600, '/', 'url.com');
This form the cookie will be set only for url.com
setcookie('YourCookieName', 'Some Values', time() + 3600, '/', '.url.com');
This form the cookie will be set to url.com
and sub-domains.
To set a cookie for a specific sub-domain, which is what you need just do:
setcookie('YourCookieName', 'Some Values', time() + 3600, '/', 'homo.url.com');
This way when accessing home.url.com
you will be logged in, when accessing prod.url.com
you will need to log in again.
Well, that’s as far as I can look at you, 'cause you didn’t post code, so I guess that’s what’s going on.
Edit
If you are not working with sub-domains, ie with paths p.x: url.com/prod
or url.com/homo
there is another issue, since for the server are equal system.
I owe a global solution for this type, not least because I avoid working with different systems separated by paths, I always try to work with sub-domains, the integrity is greater.
If you work like this the best way is for you to login to define which system the user is logging in. For example save to his Section
$_SESSION['ambiente'] = 1 // url.com/prod
When checking if the user login is active you ask what their environment is, it is to URL
What is he visiting? If it is not you force the logout to renew his login for that environment.
For further explanations, I can only see the code.
Hugs.
Isabela, the problem is when logging in, you should not be checking if there is an active login session, preventing the user from accessing the login route, and so redirecting it. When logging in always one login will unsubscribe the other because the name Sesssions are the same. If the problem is the homologation system interfering with the production problem is in the definition of Session, you do not say which url it belongs to, it must be getting every domain.
– juniorb2ss
@juniorb2ss I realized that the name of the sessions are the same, but there is no way I can change that name then? And how do I validate if there is no active session? In my accounts, he wasn’t supposed to be sharing the session because a new tab in theory would be a new instance, right?
– Isa
No, Isabella. I will post an answer, wait.
– juniorb2ss
I think it’s more @Isabela filter problem, I’m used to Java, I don’t know if PHP has this feature implemented.
– Renan Gomes