FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



May 21, 2012, 3:51 AM
68 Posts
topic has been resolvedResolved

Get Value of certain Cookie

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer,Administrator
  • Tags:
  • Replies: 3
Hi
I want to get value of certain cookie I found something like this:
 
var request = facesContext.getExternalContext().getRequest();
request.getHeader("Cookie");
 
but it show all cookies tried to edit it to show only 1 but don't work.
 
I have simply cookie named "cookie_name" and I want to get value of this Cookie.
 
EDIT
 
cookie.get("cookie_name") returns javax.servlet.http.Cookie@2a542a54
May 21, 2012, 4:54 AM
261 Posts
Re: Get Value of certain Cookie
 Karol,
 
You're close: the global "cookie" variable is a HashMap containing all cookies. The cookie.get("cookie_name") call returns an object of the javax.servlet.http.Cookie class. The properties and methods of the class can be found here. You'll see on that link that the class has a getValue() method. So, to retrieve the cookie value you can use:
 
cookie.get("cookie_name").getValue(); 
 
Mark 
May 21, 2012, 6:36 AM
68 Posts
Re: Get Value of certain Cookie
Thanks you Guys. Simon I saw this guide and I didn't see there this but Its resolved.

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.