Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF Storing data into a cookie

Tags:

cookies

jsf

I want to store some user data into a cookie so it's always there when they load the web app, even if the session has expired.

What's the best way of doing this with JSF?

like image 772
DD. Avatar asked Jul 20 '11 14:07

DD.


1 Answers

Writing to a cookie:

FacesContext.getCurrentInstance()
 .getExternalContext()
 .addResponseCookie("CookieName", "value", null);

Reading the cookie

Map<String, Object> requestCookieMap = FacesContext.getCurrentInstance()
   .getExternalContext()
   .getRequestCookieMap();
like image 145
Brian Avatar answered Oct 16 '22 19:10

Brian