I am using WordPress to set a cookie for a specified page , but it can't be done by adding the php code on the page as with PHP, cookies are set in the web page header lines, before any page content is processed.
I found a solution and it's to edit the index.php file and adding the code in the top , but this will add the code for the all pages .
So i want a php code that will get the webpage url for example
if ($pageUrl == 'http://website.com/another_page')
{
setcookie("cookie[one]","cookieone" , time()+3600*720);
if (isset($_COOKIE["cookie"]))
{
header("Location: http://website.com/page");
}
}
PS: The code above maybe broken .