I would prefer not to use javascript to set a cookie if possible. I am pretty sure it's possible to read a cookie using HTTPRequestHeader(S1), but I'd like to be able to set one when a user submits a form.
2 Answers
You can use SSJS. There's a SetValue and GetValue function for the HTTPHeader:
-
Any suggestions on how to set a cookie using SSJS? Reference this question– DanielCommented Jun 9, 2016 at 15:46
David's correct. You can do it by setting the HTTP Header, but there's a more intuitive function out there. To set a cookie with SSJS:
Platform.Response.SetCookie("MyCookie", "MyCookieValue");
The SetCookie function has a few overloaded variants:
SetCookie(string name, string value)
SetCookie(string name, string value, DateTime expirationDate)
SetCookie(string name, string value, bool secureOnly)
SetCookie(string name, string value, DateTime expirationDate, bool secureOnly)