sanrich
asked on
How to update user logout status in database table if user forcefully closes browser
Hi,
I have the requrement to update mysql database table column with user status when ever he logs out.
I can easily do this if user logsout normally from the website. Please help me how can this be done if user forcefully closes the browser.
In my sql I have the cloumn in table UserInfo
" last_logout_date` timestamp"
I need jsp or servlet code to update this column if user forcefully closes the browser.
I have the requrement to update mysql database table column with user status when ever he logs out.
I can easily do this if user logsout normally from the website. Please help me how can this be done if user forcefully closes the browser.
In my sql I have the cloumn in table UserInfo
" last_logout_date` timestamp"
I need jsp or servlet code to update this column if user forcefully closes the browser.
Identify the browser close button using javascript.Then call the servlet or java from that javascript and update the db.
I suggest using a HttpSessionListener and lowering your session MaxInactiveInterval as much as possible without irritating your clients.
There is also "onunload".
https://www.experts-exchange.com/questions/20926025/onunload.html
Or maybe use both ways.
There is also "onunload".
https://www.experts-exchange.com/questions/20926025/onunload.html
Or maybe use both ways.
ASKER
Hi
I have html as give below, I want to open another popup or page once user kills/closes the current page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Screen</title>
<script type="text/javascript" src="../js/form_validator. js">
</script>
<link href="../css/TM_Styles.css " type="text/css" rel="stylesheet" />
</head>
<body onunload="if(self.screenTo p>9000){al ert('Close d.');}">
</body>
</html>
I have html as give below, I want to open another popup or page once user kills/closes the current page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Screen</title>
<script type="text/javascript" src="../js/form_validator.
</script>
<link href="../css/TM_Styles.css
</head>
<body onunload="if(self.screenTo
</body>
</html>
I got it to work the following way.
But this stuff gets tricky.Maybe you expend your question to include the javascript zone.
https://www.experts-exchange.com/Web_Development/Scripting/JavaScript/
But this stuff gets tricky.Maybe you expend your question to include the javascript zone.
https://www.experts-exchange.com/Web_Development/Scripting/JavaScript/
ASKER
Hi Guys,
It will be great if some one can help me with this as I am not getting correct answer so far
I am looking for the way to invoke my JSP Page once some one closes the window
I found onunload can do this but looking for the syntax to open a page
<body class="" onunload="if(self.screenTo p>9000){ how to open page );}
It will be great if some one can help me with this as I am not getting correct answer so far
I am looking for the way to invoke my JSP Page once some one closes the window
I found onunload can do this but looking for the syntax to open a page
<body class="" onunload="if(self.screenTo
Sorry, I thought you had it.
firstpage
firstpage
ASKER
Thanks for the answer, but when I close the browser this page is not getting called. Is there anything else we need to do?
>but when I close the browser this page is not getting called
It works on my machine. Do have a pop-up blocker ? As I already posted above here, you should expand your question to include the javascript and the HTML zones. Maybe they have a better way. Personally I would use the suggestion I made in my first post. The listener could do the job at the server and then you would not have to deal with the browser.
It works on my machine. Do have a pop-up blocker ? As I already posted above here, you should expand your question to include the javascript and the HTML zones. Maybe they have a better way. Personally I would use the suggestion I made in my first post. The listener could do the job at the server and then you would not have to deal with the browser.
ASKER
Thanks, can you please provide me sample for HttpSessionListener. How can I implement that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.