Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Subdomain preserves cookies from main domain

I’ve set a cookie banner for a domain.com. It’s a plugin for CMS. It works with user consent – blocking or giving permission to load a GTM script.

And I have an e-shop based on PrestaShop with a cookie banner plugin, which works with the same logic.

e-shop is placed on a subdomain.domain.com.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The problem: once a user grants consent on domain.com GTM cookies are loaded, the user clicks on a button leading to subdomain.domain.com (e-shop) and all previous cookies are loaded. What is not a good behaviour for a GDPR

So, is there an easy way to clear previous cookies?

Prestashop runs on Apache server

>Solution :

From MDN:

Domain attribute

The Domain attribute specifies which hosts can receive a cookie. If unspecified, the attribute defaults to the same host that set the cookie, excluding subdomains. If Domain is specified, then subdomains are always included. Therefore, specifying Domain is less restrictive than omitting it. However, it can be helpful when subdomains need to share information about a user.

When setting your cookies, omit the Domain attribute.

This will prevent future cookies being applied to the subdomains (and will overwrite the old ones which were on the next visit which sets them).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading