Solved

session timeout

Posted on 2000-05-17
8
456 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
ID: 2816771
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
ID: 2816777
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
ID: 2817193
its  not a servlet session
0
 

Expert Comment

by:sdwr98
ID: 2817331
What kind of session are you talking about, then?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:yuvalg
ID: 2818196
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
ID: 2825246
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
ID: 2840518
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
ID: 2859179
Answer accepted
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

867 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

23 Experts available now in Live!

Get 1:1 Help Now