Foros de discusión
Accessing Cookies with Velocity
Tad Fox, modificado hace 11 años.
Accessing Cookies with Velocity
New Member Mensajes: 11 Fecha de incorporación: 19/04/12 Mensajes recientes
Is it possible to access a cookie with velocity? I've done it before with a previous velocity experience, but I'm not able to figure this out with Liferay. I would assume it would be with the cookieUtil or something like that.
Apoorva Prakash, modificado hace 11 años.
RE: Accessing Cookies with Velocity (Respuesta)
Liferay Master Mensajes: 658 Fecha de incorporación: 15/06/10 Mensajes recientes
Hi Tad,
See the following code. It may help you...
Hope this will help.
Thanks and Regards,
Apoorva Prakash
See the following code. It may help you...
#set($cookies = $request.getCookies())
#foreach($cookie in $cookies)
<b>$cookie.getName()</b> = $cookie.getValue()
#end
Hope this will help.
Thanks and Regards,
Apoorva Prakash
Roshan Qureshi, modificado hace 10 años.
RE: Accessing Cookies with Velocity
Regular Member Mensajes: 159 Fecha de incorporación: 24/08/10 Mensajes recientes
How can we SET cookie in velocity?
Regards,
Roshan Qureshi
Regards,
Roshan Qureshi
Richard Lee, modificado hace 10 años.
RE: Accessing Cookies with Velocity
Junior Member Mensajes: 28 Fecha de incorporación: 19/01/11 Mensajes recientes
I personally have been unable to get this to work in using Velocity code alone, I had to use my own JS so I would keen to find out too
s s, modificado hace 8 años.
RE: Accessing Cookies with Velocity - Freemarker
Junior Member Mensajes: 28 Fecha de incorporación: 29/01/10 Mensajes recientes
Hi, I had no problems running Apporva's code in Freemarker (an Asset Published ADT). In 6.2, I was also able to get the following freemarker code to read a specific cookie;
The CookieKeys utility has a addCookie method but I am having problems using it. Tried things like this,
<#assign aCK = objectUtil("com.liferay.portal.kernel.util.CookieKeys") />
<#assign x = aCK.getCookie(request,"COMPANY_ID") />
got x=${x}<br>
The CookieKeys utility has a addCookie method but I am having problems using it. Tried things like this,
<#assign y = aCK.addCookie(request, renderResponse, [aMyCookie]) >
without success. The "cookie" hash is quite complicated and I didn't know how to create it, and reusing a previously "get" one and changing the name did not work. The "request" and "renderResponse" may also not be right. The error I get is "No signature of method addCookie matches the arguments". Any help (code) for how to addCookie from freemarker greatly appreciated. Thanks!