This topic is locked

Session variables with two apps running

12/7/2006 7:03:40 PM
PHPRunner General questions
D
Dale author

I was quite surprised to see $_SESSION["company_name"] of one app, bleed into anther app.
I am not a power user and could really use some advice here.
I have this snippet in my supertop.php (ver 3.0)
<table class='header' border="0" cellpadding="1" cellspacing="0" width="100%">

<tr>

<td><font size='4.0em' face='Arial' color='#000000'>

&nbsp;<?php echo $_SESSION["company_name"] ?>

</font>&nbsp;ver_1.1.061206</td>

<td align='right'>

<font size='2.0em' face='arial'><strong>

<?php print date("l F d, Y"); ?>

</strong></font>&nbsp;</td>

</tr>

</table>
I have tried in both FF1.5 and IE7.

I open my first site in a tab, open my phprunner login page and sign in.

I open my second site in a tab, open my phprunner login page and sign in.
Both take me to the appropriate database and all is fine.

If I go into either one and edit the company name and save. I have and After Edit event that updates the

$_SESSION["company_name"] with the change.
But now, now matter which site I go to, the printed $_SESSION["company_name"] in the supertop are the same. EEEEK!. Im worried that maybe other $session variables are passed to each other.
The two databases are on the same server, side by side.

It will be quite common for a user to open both databases in the same browser.
Is there something I can do to assure that each of the sites retain there own session variables.

Am I just missing a point or am I in big do do here.
Thanks in advance

T
thesofa 12/7/2006

Hi

could you make one use

$_SESSION["company_name"]

and the other use

$_SESSION["company_name1"]

?

HTH

Admin 12/7/2006

Dale,
multitab browsers share sessions between tabs. To see what I mean launcn two instances of browser or both IE7 and FireFox and repeat the same login procedure.
As thesofa recommended you can use different names for different applications like App1_CompanyName and App2_CompanyName.

T
thesofa 12/7/2006

Score! I got one right!!!!!

D
Dale author 12/7/2006

Hey Sergey and thesofa
Thanks guys, I kinda thought that was happening.
That was just one example of one of my session variables.

I have a number of them to consider.
Thanks for the tips.

D
Dale author 12/8/2006

Well now Im confused and a bit bothered by this.
I did some experimenting this morning and I have some results that may be of interest to other forum members.

BE CAREFUL.
First using FireFox 1.5.
Opening two tabs in one FireFox instance, logging into each of my cloned phprunner apps.

Changing my company name in one, store it in $_SESSION["company_name"] variable would automatically effect both instances in FireFox.
Opening two separate FireFox instances and logging into one of the phprunner apps separately.

Making the company name change.

SAME EFFECT. Both separate FireFox window would update with the last change in either app.
Second using IE7
Opening two tabs and logging into each of my cloned phprunner apps.

Changing my company name in one, store it in $_SESSION["company_name"] variable would automatically effect both instances in IE7.
Opening two separate IE7 instances and logging into one of the phprunner apps separately.

Making the company name change.

No EFFECT. Each separate IE7 would hold there own info. YEAH!!!.

BUT IE7 is so deathly slow when using SSL, FireFox is 10 times faster in page display times. ERRRR!!
So obviously FireFox thinks it is smart to reuse Sessions, even between separate windows. IE7 handled it fine.
My concern here, I just noticed the company name changing as it is at the top of every page using the supertop.php. Do ALL session variables used in phprunner fall into the same area. ie
$_SESSION["UserID"]

$_SESSION["MyURL"]

$_SESSION[$strTableName."_fieldinfo"]
I feel like this can be quite dangerous for users who are used to having more than one app open at a time.

It would be an impossible task to have to rename every session variable for each app.
Is there any tricks to get each phprunner instance to use its own session variables?

Help!

Admin 12/8/2006

Dale,
here is what you can do:
in include/dbcommon.php before session_start() put the following:
// First project

session_name("project1");
// Second project

session_name("project2");
Note: the session_name() function will have no essential effect if you set session.auto_start to "true" in php.ini. And the obvious explanation is the session already started thus cannot be altered before the session_name() function --wherever it is in the script-- is executed, same reason session_name needs to be called before session_start() as documented.
Let me know how it works.

D
Dale author 12/8/2006

Thanks Sergey,
Version 3.0

I couldnt find any comment in the include/dbcommon.php re session_start.

So I assumed you meant in the templates to add the session_name("project1"); before session_start();
I tried adding it in my customer list, as this is the first page I am redirected to when I login.

When I added the command, it would not let me log in. When I tried to login in it would just bounce me

out and back to the login saying Session expired. I have no control over the php.ini.
Am I missing or assuming something.
Thanks for your attention to this.

Admin 12/11/2006

Dale,
this works with PHPRunner 3.1 only.
In PHPRunner 3.0 sessions_start() appears in every page generated.

So you need to modify all the PHP files in output folder the same way.

D
Dale author 12/11/2006

Thanks Alexey,
I will try it out and post my results. Thanks for response.

T
turbodelphi 4/15/2008

Hello, <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=27997&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
So, I had the same problem with several applications and I found a solution than I can propose to you.

In the directory source\include of your PHPRunner installation directory, modify the dbcommon.php file.

Instead of :

[indent]19.@session_cache_limiter("none");

20.@session_start();[/indent]
Add a line between line 19 and line 20 :

[indent]19.@session_cache_limiter("none");

20.@session_name(str_replace(" ", "", "##@BUILDER.strProjectName##"));

21.@session_start();[/indent]
So, each time you build a project with PHPRunner, you get an identifier with the name of your project for the session. Remember : don't give your projects long names.
Hope this helps.

D
Dale author 4/15/2008

I was surprised to see this post resurrected. Thanks for your suggestion and Im sure it will work for the conditions you have set. My condition with the bleeding through was running the same application generated with phprunner on the same machine with different browsers, and sometimes multiples of the same browser. So my solution was NOT to run the app of the same time or with the same browser multiple times. Annoying but only for the developers and admin people. Customers would never get close to this and if they did, well the bleed through is their one and only login information and resulting data.
Good solution though for folks that fall into your trap you discovered.
Thanks for the info