You can store the userid (or any string that lets you identify the
user) in the session.
In a controller:
session.put("userid", theid);
session.get("userid");
This is stored in a session cookie (signed so people can't mess with
it) so it expires at the end of the browser session. You can change
that by setting application.session.maxAge in application.conf
Ex:
application.session.maxAge=7d # remember for one week
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>
--
Erwan Loisant
// Remember if needed
if(remember) {
response.setCookie("rememberme", Crypto.sign(username) + "-" +
username, "30d");
}
It stores a signed cookie with the username that is valid 30 days.
And to retrieve it:
Http.Cookie remember = request.cookies.get("rememberme");
if(remember != null && remember.value.indexOf("-") > 0) {
String sign = remember.value.substring(0, remember.value.indexOf("-"));
String username = remember.value.substring(remember.value.indexOf("-") + 1);
if(Crypto.sign(username).equals(sign)) {
session.put("username", username);
index();
}
}
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>
--
Guillaume Bort, http://guillaume.bort.fr
For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com