Jump to content

Settings A Cookie


Recommended Posts

I'm trying to create a shopping cart for www.SweetMemoriesOnline.co.uk as i'm redesigning their website (The Payment will still be managed By Paypal)Here's my attempt of setting a cookie

<?phpif(isset($_COOKIE['smshoppingcart'])){	setcookie("smchoppingcart",$_COOKIE['smshoppingcart'],time()+3600);	mysql_query("UPDATE $tbl_cookies SET LU=(time()+3600)");}else{	$value=mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9);	$cookiedb=mysql_query("SELECT * FROM $tbl_cookies WHERE ref='$value'");	if(mysql_num_rows($cookiedb)==0)	{		setcookie("smchoppingcart",$value,time()+3600);		mysql_query("INSERT INTO $tbl_cookies (ref,LU)VALUES('$value','time()+3600')");	}	else	{		include"auto_cookie.php";	}}echo mysql_error();echo $value;echo '<br /><br />z|'.$_COOKIE['smshoppingcart'].'|z<br /><br />';?>

This is called by shoppingcart.phpa-track of their basket. I was going to use their IP but if they become disconnect and reconnect chances are a new ip may be in order.

<?phpinclude"auto_cookie.php";....

index.php (the only viewable page)

<?phpinclude"Settings/__connect__.php";$db=mysql_connect($sql_host, $sql_user, $sql_password);mysql_select_db($sql_database, $db);include"shoppingcart.php";

Anyone interested in comments i've included a quick screenshotScreenshot

Link to post
Share on other sites
setcookie("smchoppingcart",$value,time()+3600);You are setting smchoppingcart in two places in both the if and else. You might want to change smchoppingcart to smshoppingcart.
Cheers, i copied and pasted the values but type it wrong in the first statment :) lol Newbie mistake, Sorry, Working fine now :) Cheers Mate :)
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...