Nov 21, 2009

When The Browser Is Closed

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

When The Browser Is Closed

fsoftball
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

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

sobhan
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 dry.gif

 

 

 


Comment/Reply (w/o sign-up)

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


Comment/Reply (w/o sign-up)

dul
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

Comment/Reply (w/o sign-up)

(G)Sanjeev Kumar Panjaria
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

Comment/Reply (w/o sign-up)

(G)Arasu
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

Comment/Reply (w/o sign-up)

Khishigbaatar
QUOTE ((G)Arasu @ Aug 5 2009, 02:26 PM) *
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.

Comment/Reply (w/o sign-up)

(G)Sunny Srivastava
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

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : browser, closed

  1. Php Source Code Unveiled In Browser?
    is that possible? (7)
  2. Need Some Help In File Browser
    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
    places in a directory, and the files inside the sub-folders (It reads only files inside sub-folders
    and list them in simply. ) Also, it creates a directory (any name) inside each sub folder. My
    Following code reads on the files inside the main directory, it does not read the files inside the
    sub-folders.. I appreciate any help. CODE $path = "./"; $dir_handle = @opendir($path) or
    die("Unable to open $path"); while ($file = readdir($dir_handle)) { if($file == "." || $fil....
  3. Browser Problems, Maybe?
    Firefox vs IE (6)
    Alright, I coded something the other day for the game I am working on making, and a few of my
    friends I allowed to get on it and test things out. Well....the ones that were on IE their
    characters were made but the User variable as in which account they were on just stayed blank, while
    with my friends that were on Firefox, everything worked fine and they could play perfectly... So I
    was wondering, with PHP sql codes being sent to the database, is there something special you have to
    do to make it work on both, or could it be a setting on the IE that was messing with it......
  4. 2d Traveling On Browser
    PHP Game (4)
    Alright I am developing a PHP Game. I have worked on one but left them due to creative differences.
    Something that I have had trouble finding in script tutorials and script archieves is a way to do
    like a 2d mini world inside of the game. Like let's say that you have a icon for your person, it
    would put it on the map where you are at in the game and it moves as you go to different places in
    the world. something like this(horrible cause done with X's and | _): _______________________
    |_|_|_|_|_|_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|_|_|_|_|_| |X|_|_|_|_|_|_|_|_|_|_|....

    1. Looking for browser, closed

Searching Video's for browser, closed
See Also,
advertisement


When The Browser Is Closed

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com