Reputation: 1306
i have a huge problem with a system i have been assigned to maintain.
In reality it is many systems over an intranet.
The problem is, the original programmer created many systems for the intranet which all of them connect to the database through a script, where the user name, pass,db params,etc are stored in $_SESSION variables.
The problem arises when a user logs into one system, in a tab, then opens another tab for the other system, and because the session variable are overwritten he is unable to continue operating in the first one.
Take into account that there are dozens of apps... how do you think i could solve this without changing each and every existing app.?
Thanks!
Upvotes: 3
Views: 560
Reputation: 272236
You need to find ways to manipulate sessions.
One way is to use sub domains such as: app1.myoffice.local
, app2.myoffice.local
and so forth. Browsers do not share session cookies across domains.
Other trick is to change the session cookie path from /
to a sub folder. Session cookie for myoffice.local/app1/
should be limited to /app1/
, that for myoffice.local/app2/
should be restricted to /app2/
and so on.
I think you can change this setting in php via session_set_cookie_params( )
or ini_set( )
functions before calling session_start( )
.
Upvotes: 2
Reputation: 20475
This might help you:
http://www.decodephp.com/2006/11/16/php-sessions-across-subdomains-the-multiple-servers-issue/
one example from there:
I managed to create a not very invasive solution to this problem.
Its somewhat advanced in the sense it involves mod-rewrite and php image manipulation. The way I did it was to use images. For example http://something.com/something/spacer.jpg gets mod-rewrite to a script set_cookies.php?perv_id=1234&scroll=left&right_scroll=right&mascot_header=no then when you throw this up in an it will set the cookies on abc.domain.com from xyz.domain.com.
set_cookies.php sets the cookeis then pulls a 1×1 white image and displays it. So to set 9 cookies i end up with a little 9 pixel spot on my page. i have this working on the same server but it should work across multiple servers too since the variables get passed through GET
Upvotes: 0
Reputation: 321766
Move each application to its own subdomain and make sure the session cookie isn't shared - that way the user will have a separate session for each app.
Upvotes: 0
Reputation: 4755
The best thing to do would use be to try to setup session namespaces. So basically, you session data would look something like...
array("app1" => array(), "app2" => array(), "app3" => array())
Then when each up sends updates to the session, the values would be added to their respective "app containers"
Upvotes: 1