I need to grab referer and save it for the first time (I save it to sessions) and when the user gets to a specific page forward it. My problem is that after opening page with the same referer few times, I am not getting referer anymore. I tried it with few different browsers in private/incognito mode but after a few tries it gets cached and does not return anymore. My Code :
function HOOK_template_preprocess_default_variables_alter(&$variables) { $request = Drupal::request(); var_dump($request->headers->get('referer')); //stops dumping after few times $_SESSION['referer']['url'] = $request->headers->get('referer'); $variables['#cache']['contexts'][] = 'headers:referer'; }
Is there a way to save referer for every anonymous user that comes to website?
Sponsored by SupremePR