Skip to content
Advertisement

Cookie set without a name

I’m trying to set a simple cookie but the name of the cookie is never set.

I’m setting the cookie like this:

document.cookie = `${process.env.REACT_APP_TERMS_CONDITIONS_ACCEPTANCE_NAME}=true;path=/`;

The name of the cookie is not set, only content is set with the name + the value. The environment variable is defined properly since it’s displayed in the “content”.

Why isn’t ${process.env.REACT_APP_TERMS_CONDITIONS_ACCEPTANCE_NAME} defined as the name and “true” as the content? I’m doing exacly the same thing for other cookies and it’s working.

enter image description here

Advertisement

Answer

I found the issue. An extra “=” character was defined on environment variable creation. So on cookie creation, I had =name=value instead of “name=value” which resulted on the creation of a cookie without a name.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement