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
精彩评论