setMaxAge is unfortunately named -- looking at the code it appears that HTTPCookies are actually immutable, and what setMaxAge does is returns you a new cookie with the new settings.
Try: val cookie = net.liftweb.http.provider.HTTPCookie(cookieName, user.uniqueId.is ).setMaxAge(2 weeks) S.addCookie(cookie) (I took the liberty of rewriting your manual date arithmetic to TimeSpan syntax) -Ross On Oct 12, 2009, at 4:06 PM, Naftoli Gugenheim wrote: > > Firecookie (a Firebug extension) says the cookie's Expires is Session. > When I log in Firebug's Net panel shows the following response header > (I changed the cookie name): > Set-Cookie mycookiename=Z0GZIXFRBQMVTOITYSICI1XZN23ROYLN > > My code in Boot looks like this: > User.autologinFunc = Full(()=>{ > for(uid <- S.findCookie(cookieName); > userId <- uid.value; > user <- User.find(net.liftweb.mapper.By(User.uniqueId, > userId)) > ) { > User.logUserIn(user) > S.redirectTo(User.homePage) > } > } > ) > User.onLogIn ::= { > case user => > val cookie = net.liftweb.http.provider.HTTPCookie(cookieName, > user.uniqueId.is) > cookie.setMaxAge(2 * 7 * 24 * 60 * 60) // 2 weeks in seconds > S.addCookie(cookie) > } > User.onLogOut ::= { > case _ => > S.deleteCookie(cookieName) > } > What am I doing wrong? Why is the max-age not getting set? > > > On Mon, Oct 12, 2009 at 3:37 PM, Ross Mellgren <dri...@gmail.com> > wrote: >> >> I usually use FireBug or Safari Web Inspector to look at the Set- >> Cookie / Cookie headers going back and forth, or use the browser's >> built in cookie index (usually buried in preferences). You could also >> use something like Wireshark or tcpdump to watch the headers go by if >> you're using a browser that doesn't have debugging extensions. >> >> -Ross >> >> On Oct 12, 2009, at 3:15 PM, Naftoli Gugenheim wrote: >> >>> I'm writing an app in Lift that uses cookies to remember the user as >>> logged in. When I run it from my local computer, and when I run it >>> from the server and view it from my local computer, it works fine. >>> But from my client's computer it doesn't work (it seems to expire >>> with the session). How can I debug this? >>> Thanks. >>> >>> >>>> >> >> >>> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---