开发者

lift Session management

开发者 https://www.devze.com 2023-03-17 22:27 出处:网络
I am new to lift. I have been working with MVC model so far and using basic session management model i.e. storing a token in the session and check on each request.

I am new to lift. I have been working with MVC model so far and using basic session management model i.e. storing a token in the session and check on each request. I am trying to do the same with lift, but my session getting expired abruptly. even some time I just logged in and it logged out. I have analysis that whenever I gets log message like this: INFO - Session ucjrn5flnq9q1ke52z5zixgtt expired

I have searched but I couldn't find an开发者_高级运维y step by step tutor


Sessions are managed by your servlet container. Which one are you using? You should look at the container's documentation.


Do not attempt to use S.get et al to access session bound information. This is just plain dangerous. Do it like this:

class Thing {
  object SessionThing extends SessionVar[Box[String]](Empty)
  ...
  def someMethod = {
    ...
    SessionThing.is // returns you a Box[String].
    // operates on the session variable if it exists, 
    // otherwise provides a sensible default
    SessionThing.is.map(_.toLowerCase).openOr("default") 
    ...
  }
}

You need to understand the snippet and state lifecycles really, as it seems you're not fully understanding how lift's session mechanics work.


I found the solution of the problem. I was using embedded jetty server, where I was using ServletContextHandler to register lift filter. I changed it to WebAppContext and it started working fine.

Puneet

0

精彩评论

暂无评论...
验证码 换一张
取 消