Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Invalidate Session

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I validate a session if user leaves the site or closes the borwser window. To my knowledge there is no way of knowing when a user leaves the site or closes the browser window but there has to be something that I can do to destroy sesions beside reducing timeout time in web.xml. Objects that I am working with are huge and we get java heap(out of memory exception). If session is destroyed the objects that it is referencing to will become eligible for garbage collection.
Thanks
Imad
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Take a look at this.

Best regards ...
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Muhammad,

you can make a "logout" button, but you are never sure that your users will use that.

Do you really need to store that much in a user's session?

Herman
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vassili Vladimir:
Take a look at this.

I'm confused - how does this address the question?
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with terabytes of data so unfortunately cannot reduce the object size. but I appreciate your suggesstions. One thing I am thinking is use some javascript when the user is about to leave the page or close the browser and at that point call logout. do you think there is something in javascript that I can use to accomplish this.

Thanks
Imad
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you think there is something in javascript that I can use to accomplish this.


JavaScript has the onUnload event handler which you can attach to the BODY tag. It is supposed to be called just before the document replaced or closed. That could make an XMLHttpRequest call to notify the server (without waiting for the response).
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So... if I'm logged in at your site, and I use a bookmark to go to a different site, then when I click the Back button to come back to your site, I'm logged out? I don't think that's all that user-friendly myself. Maybe you should look harder at fixing the server.
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well our clients are internal to the organization. so I don't know how much user friendliness we want (I am new here). but what else would you suggest? plus using XMLHttpRequest means working with AJAX. I don't think we are looking for that.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would try to reduce the amount of data being stored in the session. Surely some of it can be reloaded from database, or wherever, instead of being cached. In fact if this isn't the case then summarily logging users off would definitely be unfriendly, as when they logged back on they would have to wait while their data was being reconstructed.

The standard method nowadays of avoiding out-of-memory scenarios is to use SoftReferences. Doing this allows the garbage collector to delete data when memory is low, on the understanding that after it does that you will know it did that and you will reload the data if you need it. That's just my quick summary, read the Sun documents about it because they explain it better.
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. We have over 500 million rows. querying again is I don't think my boss is looking for. but I really appreciate your reply. I am going to look into soft refernces.

Thanks
Imad
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you think we can use introscope to monitor active sessions?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!