#23764 [NEW]: session spans 2 or more IE windows, PHP doesn't let me create a unique session

From: Date: Thu, 22 May 2003 23:38:21 +0000
Subject: #23764 [NEW]: session spans 2 or more IE windows, PHP doesn't let me create a unique session
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40232@lists.php.net to get a copy of this message
From:             mfoxx at hotmail dot com
Operating system: RH 6.2
PHP version:      4.3.1
PHP Bug Type:     Session related
Bug description:  session spans 2 or more IE windows, PHP doesn't let me create a unique
session

Let me first state that I know my version (4.0.6) is very old, and there
are many problems with it.  There is a plan to upgrade, but in our
situation at work, it requires coordination with several servers, some of
which are offsite and out-source managed, and so we haven't been able to
upgrade yet.  I have scoured the bug list (as I do everytime I encounter
something weird/unexpected like this) to see if the problem I'm describing
has been discussed and/or fixed in subsequent versions.  I did find
several places where a similar topic was discussed, but my problem has a
different bent on that, and shows itself in a different way. I would not
be submitting this request unless I was confident that it has not yet been
addressed in the bug forum or in subsequent versions.

I have the following situation, which appears to happen on all the current
IE browsers (5+/6).  The following simple script loads into browser window
"A".

myscriptA.php:
<?php
session_start();

if (!session_is_registered("test")) $test = "blah";
else $test .= "_more";

session_register("test");

echo $test."<br>\n";

echo session_id();

?>

<a href="myscriptB.php" target="_new">Launch B</a>



The following code describes the first version of myscriptB.php, which
gets loaded into window "B" from the click in window "A":

<?php
session_start();

echo $test."<br>\n";

echo session_id();
?>

when you click the link in window "A", you get a new window, with
myscriptB.php loaded into it, and as expected, the session has spanned to
that new window, and $test = "blah", which is what is echo'd out.  Also as
expected, the session_id() has spanned so whatever it defaulted to in
window "A" is now printed out in window "B" as well.

If you go back to window "A" and you refresh the page, since $test stays
in the session, it gets the string "_more" added to it, and so on the
refresh window "A" prints out "blah_more".

Now, consider the case where I want window "B" to have its own session,
while still being launched from window "A".  That way, I could
independently destroy() either window's session or overwrite session
variables or whatever, and not have it affect the other window's session.

Ostensibly, from the documentation, it seems that session_id() and
session_name() should be able to be used to replace the current session's
id or name with a new one. This would then in affect be creating a new
session, in my understanding.

So, I changed myscriptB.php to:

<?php
session_id("newwindowB");
session_start();

$test = "newTest";

echo $test;
?>

The behavior that is expected is that window "B" will print out "newTest",
and that window "A" variables will be untouched.

However, what happens is odd, two-fold. First, window "B" does print out
"newTest". But, when you go back and refresh window "A", the session in
window "A" has been "lost".  It's not even that window "A" prints
out
"newTest" as well, window "A" thinks it has no session at all, so it
prints out just the first "blah". Weird. Then when you refresh window "A",
it takes on the session from window "B" and window "A" NOW prints
"newTest" and the session id that is printed is "newwindowB". Even
Weirder.

The goal is for window "B"s script to be able to create its own session,
and then at some point if the user chooses, have that "B" session
destroy()'d.  Then the user would simply close window "B" and go back to
window "A" and should have the session in window "A" still intact.

Why are these sessions inextricably tied together (I know it is surely
something to do with cookies)?  Is there no way for PHP to correctly
create its own NEW session at runtime, instead of just having to inherit
something from the client?

Clearly, PHP is capable of creating its own session out of thin air when
the window in question has had no session in it yet, so why can it not
overwrite that and make a new session?  It seems that the documentation on
session_id() is indicating that you are changing the session_id, and that
means its a new session, in new files/cookies/whatever. but this is not
what happens.

I've posted this on several different forums, and noone seems to
understand what to do to make this work?  Am I crazy for thinking that PHP
would be able to create a new session on demand? HELP!?
-- 
Edit bug report at http://bugs.php.net/?id=23764&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=23764&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=23764&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=23764&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=23764&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=23764&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=23764&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=23764&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=23764&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=23764&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=23764&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23764&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=23764&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=23764&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=23764&r=gnused



Thread (15 messages)

« previous php.bugs (#40232) next »