Create/Init a LiftSession from outside a Lift-handled request
This feature is extracted from a thread in the google group created by me: http://groups.google.com/group/liftweb/browse_thread/thread/9145dc69db8a4bf1
I would like to be able to create/init a LiftSession from outside a Lift-handled request and make sure that the same LiftSession is available when accessing the Lift parts of my app
Example (attached):
The attached application is a modification of the Hello World archetype with an additional /hello servlet.
sample login -- user: username=user; email=user@user.com; password=password;
I would like to be able to create/init a LiftSession from outside a Lift-handled request and make sure that the same LiftSession is available when accessing the Lift parts of my app
Example (attached):
The attached application is a modification of the Hello World archetype with an additional /hello servlet.
- When visiting the http://localhost:8080/hello servlet FIRST, the servlet displays the session Id, creates a LiftSession, and logs a user in. Subsequent refreshes of the page do NOT maintain the user's logged in state.
- Then, when visiting the Lift app at http://localhost:8080 SECOND, the index page shows the same session ID, but the user is not logged in.
- After accessing the Lift app, the servlet is able to access the existing LiftSession and successfully log the user in (or determine that the user was logged in from the Lift app)
sample login -- user: username=user; email=user@user.com; password=password;
Leave a comment
file:aSOHxkorqr36S6eJe5d-aX: Updated file
Update the session lookup/creation to:
// try to get lift session
val my_lift_session: LiftSession = SessionMaster.getSession(session.getId, Empty) openOr {
val lowSession = new HTTPServletSession(session)
val ret = LiftSession(lowSession, req.getContextPath())
SessionMaster.addSession(ret)
ret
}
And it worked.
// try to get lift session
val my_lift_session: LiftSession = SessionMaster.getSession(session.getId, Empty) openOr {
val lowSession = new HTTPServletSession(session)
val ret = LiftSession(lowSession, req.getContextPath())
SessionMaster.addSession(ret)
ret
}
And it worked.