I want to set Custom Cookie Variable with it’s value and expire date. My main goal is to set Cookie variable is depend upon the login user, Once the user is log into website the cookie variable at user’s browser is set with email address and it wll remove once the user is logged out.
I am trying to use Javascript code for this functionality.
Here is my Javascript code:
function setCookie(name, value, days) { var d = new Date; d.setTime(d.getTime() + 24*60*60*1000*days); document.cookie = name + “=” + value + “;path=/;expires=” + d.toGMTString();
Unfortunately the code is not working at Hubspot platform. Can you please help me this? How we can set, get and remove the custom cookie variable at HubSpot either using Javascript or HubL.
Hi @DProdigitas, I hope that you are well!
Thanks for asking the Community!
I’d love to put you in touch with some of our Top Experts: Hi @stefen, @alysamwilie and @Syeda_Fatima do you have suggestions to help @DProdigitas, please?
Thanks so much and have a beautiful day!
Best,
Bérangère
I tried the same code but it was not working, unable to set cookie value at user’s browser. Can you please provide us better option using JavaScript or HubL code.