In HubSpot
I'm trying to check if a cookie exists, if it does exist, I'm looking to perform an action through an if statement
. However, I cannot seem to get the cookie value using request.cookies
as outlined in their docs.
Doing the following:
{% set cookies = request.cookies %}
{{ cookies }}
Returns all the cookies. I'm looking to obtain a single cookie value in a variable.
The cookie I'm trying to obtain in a variable is named __hssluid
. Since request.cookies
is of type dict
, I've tried the following:
{% set cookie_name = "__hssluid" %}
{% set result = request.cookies.cookie_name %}
{{ result }}
But it doesn't show anything. How can I get a single cookies value using HuBL?
Have also tried the following:
{% set cookie_name = "__hssluid" %}
{{ request.cookies[cookie_name] }}
{{ request.cookies.cookie_name }}
{{ request.cookies.__hssluid }}
All the above prints nothing for me.
To get a value of a cookie with HUBL you just need to do:
without setting the cookie_name as a variable