Allow special strictly necessary cookies

How to allow special strictly necessary cookies?

Written by NelsonLast update 4 months ago

According to GDPR, strictly necessary cookies could be set in case they are required for the website to work properly. Also, not all cookies are considered private data, for example, a cookie to store visitor setting on the website, language, or cart can be set without user consent.

CookieScript allows you to assign those cookies to a Strictly necessary cookie category. However, in some cases, those cookies do not have fixed names. 

CookieScript now allows you to list those cookies and they will not be deleted when the page loads (before the user agreed to Cookie Policy). This option can be found in the Behaviour tab > Strictly necessary cookies list.

Note: Cookies listed in this section will not be shown in the cookie declaration table.

Simply list all your functional cookies comma separated, for example: 


Regular expression usage

Some systems session cookies do not have a certain name, instead, cookie names are generated randomly, like a hash value, ex: 3c70b445f566758848ec319708ce2e05 (32 symbols of alphanumeric characters).

For that, we have implemented regular expression match functionality, which means you can use a regular expression for cookie name and Cookie-Script will also not delete any cookies that match the regular expression.

Here is an example of the same "Functional cookies" option in this case:

cart, /^[a-f0-9]{32}$/i, language

In this example, 3 cookies are considered strictly necessary and will not be deleted by Cookie-Script:

  1. cookie named cart

  2. cookie with any name that has 32 symbols of 0-9 and a-f (hash-like value)

  3. cookie named language

You can use this regular expression to keep hash-like cookie names:  /^[a-f0-9]{32}$/i

For other types of randomly generated cookie names, you can build your own regular expressions.

Note: Regular expression has to start with a "/" symbol

Did this answer your question?