Hi,
I have been having trouble getting same the cookie for the same person.
When the visitor browse on my site, some of them gets a different cookie everytime they go to a different page.
But this does not happen to everyone, only to about 30% of the visitors.
This is my code
$link=mysql_pconnect($hostName, $userName, $password);
mysql_select_db($databaseName, $link);
if(!isset($_COOKIE["cartId"]))
{
session_start();
setcookie("cartId", session_id(), time()+ 3600 * 24 * 45);
// return session_id();
}
if (!function_exists('GetCartID'))
{
function GetCartId()
{
if(isset($_COOKIE["cartId"]))
{
return $_COOKIE["cartId"];
}
else
{
// There is no cookie set. We will set the cookie
// and return the value of the users session ID
session_start();
setcookie("cartId", session_id(), time() + ((3600 * 24) * 45));
return session_id();
}
}
}
?>
Can anyone spot something wrong here? Ive been trying to figure this out for a long time and finally I found this board. Thanks in advance.