Distrix
Distrix

Reputation: 13

Block ALL website cookies with JS/JQuery/PHP (and re-enable them)

How to block ALL cookies of a (Wordpress) website with JQuery / JavaScript / PHP and stop blocking / re-enable them with another script?

Background: I want to block cookies on page load and only enable them after the visitor clicked the agree button on the cookie consent banner (required due to EU law). I also want to block or re-enable cookies when the visitor re-opens the banner and changes his choice. I already have a script for this: https://cookieconsent.osano.com/documentation/disabling-cookies/, but I don‘t know how to disable and enable Cookies.

Upvotes: 1

Views: 555

Answers (1)

Quentin
Quentin

Reputation: 944568

You can't enable or disable cookies per se.

You can only not set them in the first place, set them (e.g. with a Set-Cookie header), or unset them (by setting them with an expiry date in the past).

Upvotes: 1

Related Questions