How to pass extra variables in URL with WordPress

I am having trouble trying to pass an extra variable in the url to my WordPress installation.

For example /news?c=123

For some reason, it works only on the website root www.example.com?c=123 but it does not work if the url contains any more information www.example.com/news?c=123. I have the following code in my functions.php file in the theme directory.

if (isset($_GET['c'])) 
{
  setcookie("cCookie", $_GET['c']); 
}

if (isset($_SERVER['HTTP_REFERER']))
{
  setcookie("rCookie", $_SERVER['HTTP_REFERER']);
}

Any Ideas?

65
задан Maxime 13 April 2019 в 18:04
поделиться