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

prevent to open the SAME APPLICATION (with the same session) in two or more browser windows.

P: n/a
Everybody knows how to open (or clone) the same page that you are
viewing in a new browser window by CTRL+N or via File->New Window. the
question is how to PREVENT to open the SAME WEB APPLICATION (with the
same session) in two or more browser windows.

any ideas?

ja****@gmail.com
thanks in advance!!! =)

Jan 24 '07 #1
Share this Question
Share on Google+
8 Replies

P: n/a
<ja****@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
Everybody knows how to open (or clone) the same page that you are
viewing in a new browser window by CTRL+N or via File->New Window. the
question is how to PREVENT to open the SAME WEB APPLICATION (with the
same session) in two or more browser windows.

any ideas?
Firstly, apart from under exceptional circumstances, sessions are unique
irrespective of browser and/or user. That means the same 'user' (see below)
will always have a different session every time they access the web app,
even when running two copies of the browser on the same computer at the same
time, so you're on a bit of a non-starter with that one...

Secondly, the web app will have no idea who the 'user' is unless it uses
some sort of authentication mechanism i.e. the user logs in, or uses
Integrated Windows Authentication, which is quite common in corporate
intranets etc, but highly unlikely on the public Internet.

Therefore, unless your web app has some way of 'knowing' who the user is,
there's not much you can do to prevent the same user accessing the same site
more than once at the same time.
Jan 24 '07 #2

P: n/a
Thus wrote Mark,
<ja****@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
>Everybody knows how to open (or clone) the same page that you are
viewing in a new browser window by CTRL+N or via File->New Window.
the question is how to PREVENT to open the SAME WEB APPLICATION (with
the same session) in two or more browser windows.

any ideas?
Firstly, apart from under exceptional circumstances, sessions are
unique irrespective of browser and/or user. That means the same 'user'
(see below) will always have a different session every time they
access the web app, even when running two copies of the browser on the
same computer at the same time, so you're on a bit of a non-starter
with that one...
Unfortunately, that's usually not the case. Most browsers share a cookie
jar (so to speak) when you open a new window or tab, and that's what most
users do and the OP alluded to. You have to run another instance of the browser
executable to avoid this. But at the end of the day, that's an implementation
detail of the browser.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 24 '07 #3

P: n/a
"Joerg Jooss" <ne********@joergjooss.dewrote in message
news:94**************************@msnews.microsoft .com...
You have to run another instance of the browser executable to avoid this.
That's right - that's what I said:
"even when running two copies of the browser on the same computer at the
same
time,"
Jan 24 '07 #4

P: n/a
Nope, this is what you said
" That means the same 'user' (see below)
will always have a different session every time they access the web app,
even when running two copies of the browser on the same computer at the same
time"
And this is incorrect. Most likely browsers will share same session if you
running 2 copies of the browser window on the same computer at the same
time.

George

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:u$**************@TK2MSFTNGP05.phx.gbl...
"Joerg Jooss" <ne********@joergjooss.dewrote in message
news:94**************************@msnews.microsoft .com...
>You have to run another instance of the browser executable to avoid this.

That's right - that's what I said:
"even when running two copies of the browser on the same computer at the
same
time,"

Jan 24 '07 #5

P: n/a
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:OY****************@TK2MSFTNGP05.phx.gbl...
And this is incorrect. Most likely browsers will share same session if you
running 2 copies of the browser window on the same computer at the same
time.
I just tried it. I opened 10 instances of IE7 and pointed at my website - 10
different SessionIDs...

Then I opened one instance of IE7, pointed at my website and clicked Cltr-N
nine times - 10 different SessionIDs...
Jan 24 '07 #6

P: n/a
Thus wrote Mark,
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:OY****************@TK2MSFTNGP05.phx.gbl...
>And this is incorrect. Most likely browsers will share same session
if you running 2 copies of the browser window on the same computer at
the same time.
I just tried it. I opened 10 instances of IE7 and pointed at my
website - 10 different SessionIDs...

Then I opened one instance of IE7, pointed at my website and clicked
Cltr-N nine times - 10 different SessionIDs...
Funny, IE7 and Firefox2 behave for me just as I've described (I'm testing
this with my ASP-based web mail site).

But that't no that point. The point is that this behavior (or a lack of it)
is an implementation detail, and simply cannot be relied upon.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 25 '07 #7

P: n/a
"Joerg Jooss" <ne********@joergjooss.dewrote in message
news:94**************************@msnews.microsoft .com...
But that't no that point. The point is that this behavior (or a lack of
it) is an implementation detail, and simply cannot be relied upon.
Absolutely.
Jan 25 '07 #8

P: n/a
On Jan 25, 8:57 am, Joerg Jooss <news-re...@joergjooss.dewrote:
Thus wrote Mark,
"George Ter-Saakov" <gt-...@cardone.comwrote in message
news:OY****************@TK2MSFTNGP05.phx.gbl...
And this is incorrect. Most likely browsers will share same session
if you running 2 copies of the browser window on the same computer at
the same time.
I just tried it. I opened 10 instances of IE7 and pointed at my
website - 10 different SessionIDs...
Then I opened one instance of IE7, pointed at my website and clicked
Cltr-N nine times - 10 different SessionIDs...

Funny, IE7 and Firefox2 behave for me just as I've described (I'm testing
this with my ASP-based web mail site).

But that't no that point. The point is that this behavior (or a lack of it)
is an implementation detail, and simply cannot be relied upon.

Cheers,
--
Joerg Jooss
news-re...@joergjooss.de
Ok, here's the deal: I was looking for a way to prevent users of my
website to open two or more instances of the same page. I must add
that my website is a game, so having multiple browsers opened is no
doubt an advantage. After reading this thread and trying out a couple
of things, here's what i did:
- user opens first instance of the page, he is not logged in.
- here i used javascript to attach a name to this window. the name is
a md5 hash of the php session_id , user ip, http_user_agent and
whatever else you want.
- the user logs in, then javascript checks if the window name is
correct.

- user opens another instance (Open link in new window)
- since user is already logged in, i check if the window name is still
the same . it's NOT ! .. i log out the user and force a new session
with a new id to be created and used in setting the window name.

what now ?
user has two choices: either continues to log in on this second page,
thus disabling the first page since the session id is different so the
page name will not match . this makes the first page log the user out
if accessed. Or the user will close the second page, returning to the
first but will find himself logged out.

That's it. And because of using the session id along with the ip and
user_agent this will also work if using two different browsers are
used or two different computers (IE and Firefox) : all you have to do
is put that key you created somewhere in a database, in a table where
you have your online users and checking every time to see if the user
has the same key or not.

I hope this helps and if you need a working example, I could send it
by email.

Feb 13 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.