| | Hi, I am storing data in a table based on the session id. When the user closes their browser, I want to run a quick delete so that the entery to the db with that session id is removed. How can I do this? Thanks |
| Nov 21, 2009 |
It's not really possible to detect when a user closes their browser window, per se. There are ways to do it - such as raising a window with the JavaScript OnClose() event, but that isn't reliable as not all clients are going to support it, and it could be blocked by anti-popup software and the like, as well as any number of other possible problems.
The way IPB works out which users are online is by tracking their movements with a timestamp of their last page view, and then automatically removing all session data for each user that has been inactive for a certain amount of time. Although it makes it easier that there is a login system, you would be able to use cookies, session data, or the client's IP address to track their movements and remove their session from the database when they don't refresh a page for, say, 20 minutes. Unfortunately, this isn't a 100% surefire way of doing it either, as visitors may share an IP address or block cookies or not support session information being stored, but it is probably your best bet. QUOTE(Spectre @ Sep 27 2005, 05:42 AM) It's not really possible to detect when a user closes their browser window, per se. There are ways to do it - such as raising a window with the JavaScript OnClose() event, but that isn't reliable as not all clients are going to support it, and it could be blocked by anti-popup software and the like, as well as any number of other possible problems. The way IPB works out which users are online is by tracking their movements with a timestamp of their last page view, and then automatically removing all session data for each user that has been inactive for a certain amount of time. Although it makes it easier that there is a login system, you would be able to use cookies, session data, or the client's IP address to track their movements and remove their session from the database when they don't refresh a page for, say, 20 minutes. Unfortunately, this isn't a 100% surefire way of doing it either, as visitors may share an IP address or block cookies or not support session information being stored, but it is probably your best bet. I agree, pop-ups are problem. you can store data in varible, not in database. If you want to delete data after users closes the window, it is easily to store data in varible. You can use arrays too
It is bad programming to store temporary variables in a database. Depending on what you are using the information for, there is a "best practice" solution. Since you are basing your post around the session ID and closing the browser, I am assuming that the information saved in the database is used based on a per visit basis.
In the case where you want to store information for a customer that is deleted after every visit, you should store that information in cookies. When the user leaves you never have to worry about deleting it. In addition, you could track a returning user. On the other hand, if you are just storing information that doesn't get passed to various pages, it may be best to use temporary variables and arrays, passing them through the URL. QUOTE(fsoftball @ Sep 27 2005, 02:18 AM) Hi, I am storing data in a table based on the session id. When the user closes their browser, I want to run a quick delete so that the entery to the db with that session id is removed. How can I do this? Thanks Hi, take a session boolean variable which takes that customer is using your DB and one integer variable which saves browser hadle. If customer accessing to your DB check that handle number. If handle number is different that customer trying to access from other window (I mean, opened another browser), and set that boolean variable false value. after that you can cut the accessing. Use WINAPI function to get browsers handle FINDWINDOW(). Good luck
i want to catch window close (X) button event.
When The Browser Is Closed Hi, I have an application in JSP. So when any user clicks on (X) button on browser, He must be log out from backend, but its not possible there. Or when any user hits close button He must be asked by popup window, that weather he wants to close this session. I want a popup option from which they can stop or break their session by clicking cancel or ok button. As I am using onBeforeUnload() JavaScript function, but the problem with that function is, it calls all others link on my application too. Please suggest me or give me some javascript contents. Thanks sanjeev -reply by Sanjeev Kumar Panjaria
Update database when i closed the browser
When The Browser Is Closed Hi, Advance thanks, I have created an application using asp.Net with c#. when logon the user then I will set a status is 1. Log off then status is set as 0. In case user close the browser or power off the system then database cannot be update. Please help me to update data when the browser is closing. -reply by ArasuUpdate database when i closed the browser When The Browser Is Closed Hi, Advance thanks, I have created an application using asp.Net with c#. when logon the user then I will set a status is 1. Log off then status is set as 0. In case user close the browser or power off the system then database cannot be update. Please help me to update data when the browser is closing. -reply by Arasu Use garbage collection method instead of trying to update database on browser close. Updating database at browser close is very hard and wrong way.
Restoring the time
When The Browser Is Closed Hi I am designing a quiz module with time limit, all I want is that if the browser gets closed or the internet connection gets interrupted in between the test, the user can restore the quiz exactly from where he left, I am able to restore the question instance but the timer keeps on moving even after the browser gets closed. Can anyone tell me how to pause the timer when the browser gets closed and retrieve it from the same point next time user log in. Thanxs Sunny. -question by Sunny Srivastava
Similar Topics
Keywords : browser, closed
listing all sub folders and files in them. (8) Hey I want to create a very simple file browser, so that, it reads all the sub-folders which are Firefox vs IE (6) Alright, I coded something the other day for the game I am working on making, and a few of my PHP Game (4) Alright I am developing a PHP Game. I have worked on one but left them due to creative differences. Looking for browser, closed
|
![]() When The Browser Is Closed |
Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com