473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to identify opening a new tab event

15
Hi All,

I am facing one issue related to session.

Suppose the user closes the window without Logging out, in firefox and in Safari (Mac OS) , the user will be automatically logged in,when they open a new window or a new tab.

Is there any way to identify the event of closing the window or tab, opening a new window or tab using javascript, evenif its opened using mouse or keyboard?

If any one know the solution, kindly help me.
Thanks in advance.
Apr 7 '08 #1
7 7276
acoder
16,027 Expert Mod 8TB
Rather than restricting the user opening new windows or tabs, just use a session timeout - after a period of inactivity, the user is automatically logged out. This saves the hassle of trying to detect events and other hacks.
Apr 7 '08 #2
Rather than restricting the user opening new windows or tabs, just use a session timeout - after a period of inactivity, the user is automatically logged out. This saves the hassle of trying to detect events and other hacks.
Try to kill the session in the logout page.
Apr 7 '08 #3
acoder
16,027 Expert Mod 8TB
Try to kill the session in the logout page.
That's an obvious solution, but did you read the OP's post? The problem is when users close the tab/window without logging out.
Apr 7 '08 #4
pronerd
392 Expert 256MB
Suppose the user closes the window without Logging out, in firefox and in Safari (Mac OS) , the user will be automatically logged in,when they open a new window or a new tab.
Some additional thought maybe required for this. The condition described should not be a problem.

First off you may not want to log users out just because they open a link on your page in a new tab. With tabbed browsers now being so common this probably happens often and would cause a lot of confusion for your users if they where logged out each time they selected "Open in a new tab"

Also if the user completely closes their browser then and then reopens it a new session ID should be getting generated for them. This is not entirely true with some new auto session recovering features. If they do still have the same session ID, and that is still valid (i.e. not timed out) then there should not be a problem.

If there session has timed out they should be getting forwarded to a login page.




Is there any way to identify the event of closing the window or tab, opening a new window or tab using javascript, evenif its opened using mouse or keyboard?
You could trigger a request to the server to log the user out on the onunload event for the body tag. This is not really that reliable though.
Apr 7 '08 #5
Nithu25
15
But if i am using 'onunload' it will be affected in all the events fired in that page, which i don't want.I want to catch the event of closing window only, so that i can call logout on firing that event.
Apr 8 '08 #6
Nithu25
15
And it should work in all the browsers- IE,Firefox and Safari (Mac OS).
Apr 8 '08 #7
acoder
16,027 Expert Mod 8TB
But if i am using 'onunload' it will be affected in all the events fired in that page, which i don't want.I want to catch the event of closing window only, so that i can call logout on firing that event.
I don't think you can reliably catch the window close event.

What if the user accidentally closes the window? They'd be pretty miffed if they had to login again. What's wrong with a session timeout?
Apr 8 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Amadelle | last post by:
Hi all and thanks in advance, I am stuck! I can't figure out how to identify which button was clicked on my ASP.NET page in the PostBack event? So what I am trying to do is to is to have an if...
5
by: Joey G | last post by:
How do I get the name or identify the control that caused the page postback. I need the information during page init. Reason why, because I need to tell usercontrol_1 that usercontrol_2 button was...
7
by: Grahmmer | last post by:
I have a few timers that are added to a form at runtime. I can handle the event fine, but I cannot identify which timer fired. Is there a way to do this? Timer Creation: -------------...
4
by: Me | last post by:
My form has a dynamically populated context menu, and each has the same event handler for the click event. The event need to write the text of the clicked menu item into a database, so I need to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.