I store user.displayName in the session, when users authenticate:
session.put("udn", user.displayName);
and the template renders it using:
${session.udn}
but strange things occur:
- login as “Sam”, display “Sam”;
- logout;
- login as “Jim”, display “Sam”, too!
- restart play;
- login as “Jim”, display “Jim”;
- logout;
- login as “Sam”, display “Jim”, too!
That is, it always display the first logged in user’s displayName.
debug just after the session.put:
session.put("udn", user.displayName);
Logger.debug("udn:\t" + session.get("udn"));
it prints correctly:
- login as Sam, prints “udn:Sam”;
- login as Jim, prints “udn:Jim”
also, I checked the cookie:
PLAY_SESSION contains %00udn%3A + correct value + %00:
- login as Sam, PLAY_SESSION contains
%00udn%3ASam%00 - login as Jim, PLAY_SESSION contains
%00udn%3AJim%00
How do I display the correct value? (my play app depends on play 1.2.3 & Secure module)
You should be using
${session.get("udn")}in your template. The implicitsessionvariable is just an instance of play.mvc.Scope.Session; there’s no magic in place that would allow syntax like${session.udn}. I’m not sure why that prints anything at all.