v.korbut
v.korbut

Reputation: 33

Access SessionVar from LiftSession.onShutdownSession listener

I have a SessionVar defined somwhere in my code:

object User extends SessionVar[Option[User]]

An an object which lives apart from sessions and requests.

object StatisticMonitor extends LiftActor{

    LiftSession.onAboutToShutdownSession::= onSessionShutdown

    def onSessionShutdown(targetSession: LiftSession) {
        //TODO: how to find User for session targetSession 
    }
}

Questions:

  1. Is it true that inside onSessionShutdown User is bound to targetSession (i.e. by calling User.is I'll get the user which is shutting down).

  2. Is there a way to access any SessionVar having LiftSession instance. (e.g. I have array of LiftSessions and I want to iterate over all session variables)

Upvotes: 0

Views: 135

Answers (1)

jcern
jcern

Reputation: 7848

Adding a handler to onAboutToShutdownSession will be called whenever any session expires, not just the current session which is bound to the SessionVar. If you are only concerned with the session bound to SessionVar, you probably want to override the onShutdown(session:CleanUpParam) method on SessionVar instead.

I'm not sure exactly what you want to accomplish with point two, but I don't believe you can get access to the underlying LiftSession from the SessionVar.

Upvotes: 1

Related Questions