开发者

Running code on session creation in Lift

I'd like to track the referrer URL for the first point of contact a user has in my site but only if they sign up. I'm thinking this should be accompli开发者_开发百科shed by caching S.referrer when a new LiftSession is created but how does one invoke code at session creation?


LiftSession has a hook afterSessionCreate which is a list of functions to call after a session is created. At this point SessionVars work so the referer can be stored in one until needed. The following adds a hook in Boot.scala to just display the referer:

LiftSession.afterSessionCreate = ((l: LiftSession, r: Req) => println(S.referer) :: LiftSession.afterSessionCreate
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜