Retrieving JEE session information

52 views
Skip to first unread message

Jonathan Brookins

unread,
Jan 26, 2016, 1:56:24 PM1/26/16
to Lucee
Given that I have a JEE session id (jsessionid) is there any interface to get information on the session, like when it was started, active vs inactive, that sort of info?  It's probably handled by the servlet container, but at some point the Lucee server has to know at least when it times-out, correct?

Pete Freitag

unread,
Jan 26, 2016, 2:02:31 PM1/26/16
to lu...@googlegroups.com
Yes there is a robust API for managing sessions in Java.


<cfdump var="#getPageContext().getRequest().getSession()#"> is the HttpSession...


--
Pete Freitag
https://foundeo.com/ - ColdFusion Consulting & Products
http://hackmycf.com - CFML Server Security Scanner


On Tue, Jan 26, 2016 at 1:56 PM, Jonathan Brookins <jon.br...@gmail.com> wrote:
Given that I have a JEE session id (jsessionid) is there any interface to get information on the session, like when it was started, active vs inactive, that sort of info?  It's probably handled by the servlet container, but at some point the Lucee server has to know at least when it times-out, correct?

--
Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/c2f35856-d890-47f7-bd4d-5978a5d6c4b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonathan Brookins

unread,
Jan 26, 2016, 2:27:17 PM1/26/16
to Lucee, pe...@foundeo.com
Thanks, Pete, but what I am looking for is a way to get the session info outside of using page context using only the session id.  I'm trying to build a page that will show me details on current server sessions by application name.  Here is what I have so far:


for ( config in getPageContext().getConfig().getConfigServer('mypassword').getConfigWebs()) {
 context
= config.getFactory().getScopeContext();


 
//dump(config.getServletContext().getServletRegistrations());


 cf_session_scopes
= context.getAllCFSessionScopes();


 cf_session_scopes_active
= cf_session_scopes.filter(function(scope) {
 
return !cf_session_scopes[scope].isEmpty();
 
});


 
dump(cf_session_scopes_active);
 
}

Igal @ Lucee.org

unread,
Jan 26, 2016, 2:34:01 PM1/26/16
to lu...@googlegroups.com
I haven't tried it with JEE sessions, but with CFML sessions this function works so you can give it a try (and please let us know):

    function getAllSessions(appName="") {

        if (isEmpty(arguments.appName))
            arguments.appName = Application.ApplicationName;

        return createObject("java","coldfusion.runtime.SessionTracker").getSessionCollection(arguments.appName);
    }

Igal Sapir
Lucee Core Developer
Lucee.org

Jonathan Brookins

unread,
Jan 26, 2016, 2:40:52 PM1/26/16
to Lucee
Igal,

That SessionTracker code essentially gives me the same info as getAllCFSessionScopes(), probably because getAllCFSessionScopes() uses it internally, I'd guess.

Igal @ Lucee.org

unread,
Jan 26, 2016, 2:43:26 PM1/26/16
to lu...@googlegroups.com
ok, so what are you looking for exactly?  you can easily create another function, like so:


    function getSessionData(SessionId, appName="") {

        var allSessions = getAllSessions(arguments.appName);

        if (allSessions.keyExists(Arguments.SessionId))
            return allSessions[Arguments.SessionId];

        return {};
    }



Igal Sapir
Lucee Core Developer
Lucee.org

Reply all
Reply to author
Forward
0 new messages