PHP session problems (Firefox shares sessions)!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mattward211
Forum Newbie
Posts: 1
Joined: Tue Nov 28, 2006 1:19 pm

PHP session problems (Firefox shares sessions)!!

Post by mattward211 »

I'm running WinXP PHP 5.1.2 and Apache 2.0.59. My problem is when I pass sessions from one page to another. I have one page that has a single input box and a submit button. When you hit submit it assigns the post value to a session value as follows:
$_SESSION['userid'] = $_POST['id'];
Yes session_start() is on top of the page.
After this I have a link to another page that simply displays the session value like so
print $_SESSION['userid']. In IE6 and 7 everything works fine even with TWO windows open. I can type different values in the input box on the first window, submit it, and refresh the second window and the data doesn't change (what I want) think two different people logging in on the same PC with two different windows. I don't want the other to get the values.
However in FireFox with different windows open they "share" the values. So if I log in in the first window as a normal user, then open a second window log in as an admin, refresh the first window, I get the admin session info. in my case just a user id for right now.

Any ideas as to how to prevent this?? :twisted:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Typically Internet Explorer will share the session data if the second window was created from the first. If you start it again it will often run under a separate process and not share data. I remember there being a setting for this behavior.

I don't recall if Firefox will do the same as I rarely have two windows open.
Post Reply