|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-05-22 18:46 UTC] mfoxx at hotmail dot com
[2003-05-22 19:07 UTC] magnus@php.net
[2003-05-22 20:04 UTC] mfoxx at hotmail dot com
[2003-05-22 20:05 UTC] mfoxx at hotmail dot com
[2003-05-22 20:08 UTC] rasmus@php.net
[2003-05-22 20:16 UTC] mfoxx at hotmail dot com
[2003-05-22 20:30 UTC] rasmus@php.net
[2003-05-23 09:22 UTC] mfoxx at hotmail dot com
[2003-05-23 10:09 UTC] sniper@php.net
[2003-05-23 11:21 UTC] mfoxx at hotmail dot com
[2003-05-23 11:32 UTC] rasmus@php.net
[2003-05-28 03:44 UTC] heng at yahoo dot com
[2003-05-28 12:36 UTC] mfoxx at hotmail dot com
[2003-06-13 16:28 UTC] ky at jelly dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 06:00:01 2025 UTC |
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!?