Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Finding If a Session  is Valid using the Session ID

Posted on 2002-03-18
3
Medium Priority
?
187 Views
Last Modified: 2010-04-01
Hello All,
     I am currently working on a web application where in
a user is allowed to edit a particular record. I will have
to restrict 2 users from editing the same record, for this
reason i am using the Session Id of the user to know which
user is editing a particular record.

     I have a seperate table which stores the entries like
the record (unique identified) and the session id. Each
time a person is about to edit or delete a particular
record i go and see if  that particular record is being
edited by another user.

    Now the problem is if the session has expired, i don't
have a control of the record which i had created. So if
another user tries to update or delete he is still not able to edit or delete that particular record.

    Now i have the Session Id of the user who started
editing that particular record, now i will have to find
out if the session is valid.

    Can any one help me out to solve the above problem.
I am current using tomcat 3.2.3 on Red Hat Linux .


V. Ramkumar.

any other user
0
Comment
Question by:V_Ram
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
kotan earned 300 total points
ID: 6879091
You can use event/listener method to delete the record which had created. Here is the steps:

Create an object which implement HttpSessionBindingListener. This object will be stored in a session.
Then, you should implement the valueBound() and valueUnBound() method. The valueUnbound() method will
be trigger if this object being unbound (This happen when the object is being replaced and session  
is invalid). In here, you can get the invalid session and delete away the record from the database.

public class BoundObj implements HttpSessionBindingListener {
   public BoundObj() {}
   public void valueBound(HttpSessionBindingEvent be) {
        // Will be trigger when this object being bound.
   }

   public void valueUnBound(HttpSessionBindingEvent be) {
       HttpSession hs = be.getSession();
       String userid = hs.getAttribute("userid");
       String sessionid = hs.getID();
       ....
       // Delete database record.
   }
}
At the time the user login which you create a new session, put the bound object in that session.
session.setAttribute("boundobj", new boundObj());
0
 

Author Comment

by:V_Ram
ID: 6882031
Hello Kotan,
   It Did Work , thanks for you timely help. By the way
does this class gets a message when the Browser is closed.

V. Ramkumar.


     
0
 
LVL 6

Expert Comment

by:kotan
ID: 6882038
if the browser is closed,then it will wait until the session expire to get the message.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes Administrators rights are not enough. These cases call for the SYSTEM account. The process in this article outlines the steps required to execute commands using the SYSTEM account.
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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