English 中文(简体)
Scala and Lift and SessionVar that loses it contents
原标题:

I have SessionVar like this in Lift:

object MyObject {
   object myVar extends SessionVar[Box[MyObject]](Empty)
}

Then I set value once for myVar:

 MyObject.myVar(Full(value))

My problem is that after some time (1-5 mins) myVar will lose its value, that is, it will have value Empty again. This is not due inactivity since I am clicking pages constantly. My code is not setting value to Empty. During this 1-5 mins the myVar will work correctly. The logs contain no related messages.

I tried to add shutdown method to myVar, but it is not getting called.

 override protected def onShutdown(session: CleanUpParam): Unit = {
   Log.error("shutdown executed")
 }

I am running Lift in jetty via mvn jetty:run command. I am using 1.1-SNAPSHOT of Lift. I am not creating explicitly any kind of cookie or session.

Any ideas what is happening? It could be that session expires or invalidates somehow, but why and by whom?

I even tried to disable liftGC with (LiftRules.enableLiftGC = false) but that does not affect.

最佳回答

I imagine that the issue is that while clicking around, you are accidentally creating a new session. That would explain why you re not getting the session shutdown event: the old session still exists, but you re no longer using it. I suggest that you print out the session ID with each request and see if it changes.

You might be losing the session because the session cookie is expiring, or because you aren t URL-encoding some links (see HttpServletResponse.encodeURL), or because you are navigating outside your application s context path.

问题回答

What s your session expiry time set in LiftRules?





相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签