Different sessions in different windows?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

The title says it all - I'm doing sessions with cookies. I can divide the
data within the session easily enough but I can't see when the user creates
a new window or closes an old one.



Re: Different sessions in different windows?

What happens on the client web browser is not necessarily communicated to
the web server. You cannot tell when the user creates or closes a browser
window as nothing is sent to the server. The only time that the server knows
what happened is when it receives an HTTP request (using either the GET or
POST methods).

Tony Marston


Quoted text here. Click to load it

Re: Different sessions in different windows?

Quoted text here. Click to load it

   Opening new window by pressing Ctrl+N shouldn't generate a new
session on any circumstances. For the other case, i.e., closing the
browser and restarting, you may try persistent session cookies (cookie
with life time>0).

  session.cookie_lifetime <http://in.php.net/session

|  Just another PHP saint  |
Email: rrjanbiah-at-Y!com

Re: Different sessions in different windows?

Colin McKinnon wrote:
Quoted text here. Click to load it

This is something out of your control. PHP being serverside you just
have to accept the fact that clients with their array of browsers and
software will be requesting your pages from the server handling them
clientside in which ever way they prefer. Some browsers can instantiate
new windows, others might do it in another manner. Your server or the
script has no way of controlling that or even knowing if it is happening
or not.

Through javascript you could make some complicated scripts that interact
with PHP when the client opens new windows or does some wacky stuff, but
this just _might_ work in the mainstram browsers after a lot of work and
experimenting, and even then just turning off javascript would destroy
it. Relying on javascript or any other hacks like this should be
strongly discouraged.

Programming for the web has its limitations, or rather, requires a
different way of thinking than the common clientside programming.

It would help if you told in more detail what it is that you are really
trying to do. If you wish to have the same client operating the
script(s) with many browsers/windows/accounts at the same time, you
might need to start carrying some kind of unique id's with all pages
manually instead of sessions (since they get shared with different
windows of the same browser). This might not be as big of a deal as you
might think (output buffering, includes and perhaps a class doing the
stuff automatically might be something to take a closer look at).


Site Timeline