getting client cookies name and value
What is the best way to A: check that a cookie of name "cookie-a" has been set in the client, and B: to get the value and expiration of cookie-a?
I can do this fairly easily with javascript (document.cookie();) and have confirmed that the cookie really is there.
I have used the documentation here: http://lithosphere.lithium.com/t5/developers-knowledge-base/http-request-FreeMarker-context-object/ta-p/9323 to produce:
<#assign myCookie =http.request.cookies.name.cookie-a />
<#if myCookie.value == "value">
{do stuff}
<#/if>
but it throws an error
also if I print myCookie.name I just get whatever name I used in the request (regardless of whether it exists on the client or not).
Please tell me the correct syntax for getting a cookie's value!
Thanks!
Hi,
this should work:
<#assign cookie = http.request.cookies.name.get("cookie-a") /> <#if cookie?? && cookie.value?? && (cookie.value == "value")> todo </#if>