By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

Different sessions in different windows?

P: n/a
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.

TIA,

C.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

http://www.tonymarston.net

"Colin McKinnon" <co**************@andthis.mms3.com> wrote in message
news:ck*******************@news.demon.co.uk...
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.

TIA,

C.

Jul 17 '05 #2

P: n/a
Colin McKinnon wrote:
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.


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).

--
Suni

Jul 17 '05 #3

P: n/a
Colin McKinnon <co**************@andthis.mms3.com> wrote in message news:<ck*******************@news.demon.co.uk>...
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.


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
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.