aspose file tools*
The moose likes JSP and the fly likes Update database for logout when signout is not done properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Update database for logout when signout is not done properly" Watch "Update database for logout when signout is not done properly" New topic
Author

Update database for logout when signout is not done properly

Indresh yadav
Greenhorn

Joined: Nov 03, 2009
Posts: 1
Hi ,
I am facing problem related with sign out...
the problem is...

i mentain a database related with loggedin and looggedout.
filed loginId contains value 1 when user loggedin.and 0 when user logged out.
if user signout properly thing are going well no problem..

but when user used to closed browser by using X without signing out...then database field loginId not changed and having value 1 for that user....

i need to update this field to 0 when user closed browser by using X.

thnks in advance..
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Indresh yadav wrote:
i need to update this field to 0 when user closed browser by using X.


There is no reliable way of achieving this, I'd suggest to update the database when the user's session expires instead (e.g. HttpSessionListener).


OCJP 6 (93%)
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

and Welcome to Javaranch
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi Indresh, recently I have seen a website implementing your problem, it is www.reliancebroadband.com.
When we login the session is created with a logout link. If we want to logout we use the logout link. If the user tries close the window directly, then a confirm dialog box appears asking the user that he/she is sure to close the window. If the user clicks yes then session is expired and and some database transactions are done, if he clicks no he will remain in the same page. This is possible with javascript.
This is how you have to do this.
However there is another problem if you go with login and logout status. Think that there is a sudden power cut, than what is the situation.


Love all, trust a few, do wrong to none.
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
anusha chaitanya wrote:This is possible with javascript.


JS can be disabled...
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Lorand Komaromi wrote:

JS can be disabled...


Yes, this is also one of the factor to be considered.
 
Consider Paul's rocket mass heater.
 
subject: Update database for logout when signout is not done properly