I cannot work out why the cookie on my computer does not match the cookie id stored in the MySQL database.
I have this function creating a cookie
And this code is used to enter the cookie ID into MySQL table (add an item to the basket):
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table
// There is no cookie set. We will set the cookie
// and return the value of the users session ID
setcookie("cookieid", session_id(), time() + ((3600 * 24) * 4));
But then another query says this (get data about products added to basket only for user with particular cookie on their computer):
@mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)");
This mysql query does not work. The problem is the "cart.cookieId='" .GetCartId() ."'". Without this it is fine. With it, it does not work.
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");
As you can see above the cookieId is defined by the GetCartId function. As far as I can tell it must match but with this bit of code it does not work.