ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | enhydra List | Febuary 2005 Index

<--  Date Index  --> <--  Thread Index  -->

Re: [enhydra] deleteSession() doesn't work?


Hi Petr,
I remember running into this one quite a while back (on Enhydra 3.1 actually) - while all session keys are visible from the session manager, the deleteSession(String) method wouldn't work on any session other than the current session. At the time, the final version of our code for preventing concurrent sessions under the same user didn't end up needing to overcome this restriction. Taking a closer look at the Enhydra source code, the trouble seems to be that the deleteSession(String) method in the StandardSessionManager class calls the getSession(String) method on the BasicSessionHome object (the javadoc for this method says that the session must already be in the 'active' state for the current thread or null is returned), rather than getSession(Thread, String) method (the javadoc for this method says that this method will also put the session into 'active' state for the specified thread):

public synchronized void deleteSession(String sessionKey) throws SessionException {
   Session session = (Session)sessionHome.getSession(sessionKey);
   if (session != null) {
       deleteSession(session);
   }
}

I'm not sure if this a bug in the session manager, or the intended functionality - if it is actually a bug, the patch would be:

public synchronized void deleteSession(String sessionKey) throws SessionException { Session session = (Session)sessionHome.getSession(Thread.currentThread(), sessionKey);
   if (session != null) {
       deleteSession(session);
   }
}

In any case, an acceptable workaround for you right now would be to replace the line that deletes the session with:

comms.session.getSessionManager().deleteSession(
comms.session.getSessionManager().getSession(Thread.currentThread(), seskey));

or

comms.session.getSessionManager().getSession(Thread.currentThread(), seskey);
comms.session.getSessionManager().deleteSession(seskey);


Based on what I see in the Enhydra 5.1 source, either of these should do the trick.

Hope that helps...
Mike.

----- Original Message ----- From: "Petr Stehlik" <pstehlik@xxxxxxxxxx>
To: <enhydra@xxxxxxxxxxx>
Sent: Tuesday, February 15, 2005 12:38 PM
Subject: [enhydra] deleteSession() doesn't work?


Hi,

trying to prevent users from logging in several times. Based on the
comment in API DOC for setUser() I am trying to delete other sessions
with same User before calling setUser() for the current session.

Code looks as follows:
====================================
// session manager: make sure there is no other session with same name logged in java.util.Enumeration e = comms.session.getSessionManager().getSessionKeys(this);
if (e.hasMoreElements()) {
String seskey = (String) e.nextElement();
comms.session.getSessionManager().deleteSession(seskey);
}

// session: set current user
comms.session.setUser(this);
====================================

Unfortunately the deleteSession() doesn't work. The session key is
correct but it doesn't delete the session. Any idea why?

Petr






--------------------------------------------------------------------------------



--
You receive this message as a subscriber of the enhydra@xxxxxxxxxxxxx mailing list.
To unsubscribe: mailto:enhydra-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws





<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.