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?
Advertisement
Answer
There are quite few solutions to tackle this issue. First you can go for a plugin if you want:
Or code manually, check out this post:
Also check out: