Forums de discussion

[Solved] how to set and read cookies in renderRequest and portletRequest

Paolo Pilitti, modifié il y a 10 années.

[Solved] how to set and read cookies in renderRequest and portletRequest

Junior Member Publications: 51 Date d'inscription: 13/04/11 Publications récentes
hi all

I'm struggling to read and set cookies in request response

can someone explain a clear way to :

1) set cookies in renderResponse and resourceResponse
2) read cookies in renderRequest and resourceRequest?


in more detail i can set the cookies in resourceResponse and read in resourceRequest but i can't ( and i want to)read the values from renderRequest
venka reddy, modifié il y a 10 années.

RE: ! how to set and read cookies in renderRequest and portletRequest

Regular Member Publications: 231 Date d'inscription: 23/03/11 Publications récentes
In Liferay , username is setting in cookie by using HttpRequest and HttpResponse objects, Look into the LoginUtil.java

Follow the below URL not exact your looking may be it will helpful to you

Setting Cookies in Liferay.


if you find anything additional , do share .
thumbnail
ritresh girdhar, modifié il y a 10 années.

RE: ! how to set and read cookies in renderRequest and portletRequest

Junior Member Publications: 67 Date d'inscription: 15/07/11 Publications récentes
Hi

First of all you need to get HttpServletResponse from PortletResponse. then only you can set Cookie in response.

Ex:
HttpServletResponse response = PortalUtil.getHttpServletResponse(portletResponse);
Cookie cookieParam = new Cookie("cookieParam ", password);
response.addCookie(cookieParam);


Regards
Ritresh
Paolo Pilitti, modifié il y a 10 années.

RE: ! how to set and read cookies in renderRequest and portletRequest

Junior Member Publications: 51 Date d'inscription: 13/04/11 Publications récentes
thank all,

the cookie started work when i set version

myCookie.setVersion(0)

regards

Paolo