I have a module with an event subscribe that I use to redirect to an age verification page if a cookie is not set, and as long as the current request is not the age verification uri.
if(!isset($_COOKIE['age_gate_ok']) && $request != '/age-verification')
{
$welcome = new\Symfony\Component\HttpFoundation\RedirectResponse("/age-verification");
$welcome->send();
}
Problem: the event seems to listen once only, and that is when I use drush to clear cache. To further explain, I use clear site cache using drush and when I reload the page, it redirects me to the correct page(/age-verification) and then I pass the gate. However, if I open the inspector to clear cookies and refresh the page, the site does not redirect me to the age verification url.
How do I have to clear cache in order to have the age verification working?