Re: new session in new window

From: Date: Tue, 09 Mar 2004 04:39:30 +0000
Subject: Re: new session in new window
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-179867@lists.php.net to get a copy of this message
On 8 Mar 2004 Tim Traver wrote: > I sent a new session ID with the link to the new window like this : > > <a href="?PHPSESSID=123456789" target="_blank"> > > but all it does is change the current session id to the new one, so if I go > back to the main window, it carries the new session into it. I think this is trickier than it sounds. Calling session_name with the new name just prior to calling session_start should do it if you know what name to set. But where are you going to get the name? If it is hard-coded you are OK but if it is dynamic, as it has to be with user logins, you need a place to store the session name -- and you can't use sessions to do it! You end up having to pass at least something in the URL, even if it is just a digit: print("<a href=\"?$sessnum\" ...>"); the URL would be something like: http://www.mydomain.com/page.php?1 from which you do something like: session_name("PHPSESSID" . $_SERVER["QUERY_STRING"]); session_start(); (obviously some error-checking might be beneficial as well). I don't think you can do what you want with sessions alone. HTTP is "too stateless" for that! -- Tom

« previous php.general (#179867) next »