Solved

session timeout

Posted on 2000-05-17
8
457 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Expert Comment

by:sdwr98
ID: 2817331
What kind of session are you talking about, then?
0
 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

776 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