Solved

session timeout

Posted on 2000-05-17
8
455 Views
Last Modified: 2010-04-01
how do i go about killing off a session with a unique ID and a timeout value providing that sessionID is *not* used within the timeout period ...
0
Comment
Question by:knor
8 Comments
 
LVL 3

Expert Comment

by:Laminamia063099
Comment Utility
I assume you're talking about a servlet session.  If so, call the session object's method:
  setMaxInactiveInterval(int intervalInSeconds);

for the session that you desire, and the session will be killed by the servlet engine if not used within the number of seconds specified.

I hope this is helpful.  

Laminamia :)
0
 
LVL 1

Expert Comment

by:cheeku_76
Comment Utility
hi!
for the setting session time u can use Session.setmaxInactiveInterval().
this will check for the inactive time and then remove the session.

if u want to terminate a session then use session.Invalidate().

i think this may help u

or else refer to any books or tutorials for this.

bye
srikanth
0
 

Author Comment

by:knor
Comment Utility
its  not a servlet session
0
 

Expert Comment

by:sdwr98
Comment Utility
What kind of session are you talking about, then?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 3

Expert Comment

by:yuvalg
Comment Utility
Your question is not so clear but -
if i understand the question correctly what you need to do is add a member to your session object that will state the last time the session has been accessed.
Within each access to this particular session object, stamp that member with the current time.

Then, when doing your cleanup, validate or invalidate the session according to that members value (see if the session has been inactive for an unaccepted amount of time).

yuval.
0
 

Author Comment

by:knor
Comment Utility
Yuval, you are on the right track to what i need.... but what is the best way to do this.... threads or a listener or ??? thanx in advance - knor
0
 

Accepted Solution

by:
harish_venk earned 65 total points
Comment Utility
First of all you will need a timer class, a timer listener interface and a session class which implements this interface. You have to create a session object for each user and store the user's info in the session object. Then you can have a unique id associated with each object, say, in a hash table. Then you can append this to the end of each request URL (URL rewriting).

When this is done, whenever a user requests for a html, his session id can be retrieved from the url and checked in the hash table.

Now the timer class keeps running (its a thread) and wakes up the listeners after some timeout. You could call the method to be implemented by the class which implements the Listener interface. In this method you could increment a value (equivalent to the sleep value in the timer) and check if it has crossed the time out limit. If so then invalidate the session object.

Most important thing to remember is to clear the value in the class that implements the listener, whenever an access is made by the user. This way if a user does not perform any access for a stipulated period of time, then his session gets invalidated.

Hope this helps.
0
 

Author Comment

by:knor
Comment Utility
Answer accepted
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now