473,770 Members | 7,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to identify opening a new tab event

15 New Member
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 7297
acoder
16,027 Recognized Expert Moderator MVP
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
abhishekbrave
79 New Member
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 Recognized Expert Moderator MVP
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 Recognized Expert Contributor
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 New Member
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 New Member
And it should work in all the browsers- IE,Firefox and Safari (Mac OS).
Apr 8 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
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
16044
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 statement like as follows in the PageLoad: private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { //do something here } else {
5
5043
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 clicked and therefore need usercontrol_2 public properties to be passed to usercontrol_1 public properties in the case of the event. thanks
7
2152
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: ------------- ....some code... Dim usersTimers(4) As System.Windows.Forms.Timer For i = 0 To 4
4
2510
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 either pass that to the event handler, which I cannot figure out how to do, or access the properties of the sender, which I also cannot figure out how to do. The context menu items are a list extracted from a database, using the code below in...
0
9592
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10004
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.