Im trying to make a cookie be created if an image hyperlink on a page is clicked on. Ive managed to create a separate file which makes a cookie:
cookie.php
<?php
if cookie($companyName) {
if (isset($_COOKIE["company"])) {
$company = $_COOKIE["company"];
$company = $_COOKIE["company"].' '.$companyName;
setcookie("company", $company, time()+60*60*24*30);
}
}
else {
setcookie("company", $companyName, time()+60*60*24*30);
}
}
?>
This looks for the cookie company, if it exists, adds the new value to the current one, else creates a new cookie.
Im having trouble initialising it though, from the original page ive put:
$cookie = ("http://localhost/project/cookie.php?companyName=$companyName");
echo '<A HREF ='.$search.' onClick="include('.$cookie.')">';
Where $search is the link. In the source code, the onclick seems correct, though nothing is set, any ideas?
Also, does anyone know if this cookie would be available from another page assuming that they are in the same directory?
Cheers