Jump to content
xisto Community
Sign in to follow this  
fsoftball

When The Browser Is Closed

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

189759[/snapback]


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 :huh:

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

189702[/snapback]


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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Update database when i closed the browserWhen 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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Restoring the timeWhen The Browser Is ClosedHiI 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.ThanxsSunny.-question by Sunny Srivastava

Share this post


Link to post
Share on other sites
logout the user when browser closed?When The Browser Is Closed

hi,

I developed one application.In that application I hav login module, here once user is login I am storing that user details in a table(oracle) with session id,her I am facing one problem that if user suddenly closed the browser or due to some probles if browser is closed? at that time how can that user ll logout?I want the program in java using jsp and struts.

advanced thanks...

-reply by mabu

Share this post


Link to post
Share on other sites
Re: Restoring the time When The Browser Is ClosedWhen The Browser Is ClosedReplying to (G)Sunny SrivastavaSimple answer: you can't.At least not easily.Probably the best thing you can do, is to use auto-refresh. However that should be easy to work around, so cheating might be as easy as pressing the "STOP" button in your browser, paste the URL into another browser window, and re-start from there.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.