This topic is locked

Problem with _SESSION on multi-tab browsers

12/2/2008 2:30:17 AM
PHPRunner General questions
J
jaflores author

Hi, I'm did 2 sample projects, one admin and another customer, each with their own subset of tables from the same mysql database
anyway, I just realized that when following (both when using firefox or IE multi-tab):

  1. Open a tab and I login to the admin project as jake
  2. I open another tab and login to the customer project as cust1
  3. I go back to the 1st tab (admin) and edit a record.
  4. Now, I'm the admin project but is logged in as cust1
    In the problem above, the _SESSION["UserId"] was being shared / gets mixed up...
    Is there a way for me to make it so that the _session variables for both projects are unique to each tab?

J
Jane 12/2/2008

Hi,
it is browser-related problem. All session variables are shared between tabs.

In short, the answer is, there isn't any way of creating a brand new session with each new tab. The only way is by opening a new instance of IE or Firefox each time.

S
steveh 12/2/2008

Not quite true, what you need to do is to find the session_starts and provide a unique name (the name of each project maybe) to these.
Jane, this would be a useful addition to phprunner to save manual edits?
That way people could decide whether code shoudl or shouldn't share a common set of session variables.

J
jaflores author 12/2/2008

Not quite true, what you need to do is to find the session_starts and provide a unique name (the name of each project maybe) to these.

Jane, this would be a useful addition to phprunner to save manual edits?
That way people could decide whether code shoudl or shouldn't share a common set of session variables.


Thanks to both o you.
Steve, may I ask further how I go about doing what you suggest. The _SESSION["UserId"] is something automatically generated/created by runner. Can I just do a multi-file find and replace and change UserId to say AdminUserId in one and CustUserId in the other to make sure they are both defined unique?
Jane, will it be possible to find and replace the UserId and change it? I mean I'm afraid that if I do this, there would be some conflict I know nothing about?

J
Jane 12/3/2008

Hi,
do you use two separate PHPRunner projects or one project and two users (Admin and Customer)?

S
steveh 12/3/2008

You need to look at the php site for session_start which will allow you to run multiple projects simultaneously within a browser.

J
jaflores author 12/3/2008

Hi,

do you use two separate PHPRunner projects or one project and two users (Admin and Customer)?


Hi Jane,
Two separate PHPRunner projects.

J
jaflores author 12/3/2008

You need to look at the php site for session_start which will allow you to run multiple projects simultaneously within a browser.


Hi Steve,
Thanks, will do that...

J
jaflores author 12/3/2008

Hi Jane, Hi Steve,
Thanks for all the help...
Took Steve's advice and looked up session_start, from session_start, found session_name...
From some preliminary checks, i think it works already...
basically I edited the dbcommon.php in the both include folders and added session_name("admin); and session_name("customer"); above the session_start(); lines...
seems to work now...
err, if you find anything wrong with this, please lemme know...
thanks again!