Forum Discussion
Koni_51721
Cirrus
Aug 02, 2013How to get the session duration with iRule
Hello
We need to log the authenticated session-duration with an iRule. But with following rule, we can't get any information, the ACCESS::session variables are empty.
Has anybody an idea?
Thanks
when ACCESS_SESSION_CLOSED {
set sessionId [ACCESS::session data get "session.user.sessionid"]
set startSession [ACCESS::session data get "session.user.starttime"]
set endSession [clock seconds]
set status [ACCESS::session data get "session.policy.result"]
log 10.10.10.10 local6.info "\|SessionID: $sessionId \|StartSession: $startSession \|EndSession: $endSession \|AuthStatus: $status \|\n"
}
1 Reply
- Kevin_Stewart
Employee
The ACCESS_SESSION_CLOSED event is only triggered when "user logging out explicitly, timeout or if terminated explicitly by admin" (https://devcentral.f5.com/wiki/iRules.ACCESS_SESSION_CLOSED.ashx). Otherwise it is extremely difficult to know for certain when a user session ends - when the user closes the browser, the machine blows up, the user locks the screen and leaves for lunch, etc. Your best bet, potentially, would be to catalog the time for each new request, overwriting the last time, so that when a user stops making requests (for whatever reason) you have a general idea when the user stopped working within the application. You could simply store that time in a custom session variable in every ACCESS_ACL_ALLOWED event.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects