SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Cookie value not being set
-
Nov 17, 2003, 05:45 #1
Cookie value not being set
I am doing a shopping cart which was working OK until I put the instruction
Code://delete cookie setcookie("cartId");
Now the value for the cookie has disappeared AND IT REFUSES TO SET A NEW COOKIE.
I emptied the shopping cart AND cleared the cookies off the computer.
The output to the code below is:
Code:echo $sql; gives the output: insert into cart(cookieId, ITEMID, QTY,COLOR,SIZE) values ('', 1247001, 5, '' ,'')
Any ideas please?
Code:include("db.php"); // Get a connection to the database $cxn = mysql_connect($dbServer, $dbUser, $dbPass, $dbName) or die (mysql_error()); $db = mysql_select_db("oscart", $cxn) or die(mysql_error()); $sql = ("insert into cart(cookieId, ITEMID, QTY,COLOR,SIZE) values ('" . GetCartId() . "', $ITEMID, $QTY, '$COLOR' ,'$SIZE')") or die(mysql_error ()); //look at sql echo $sql; ShowCart();
:
:
-
Nov 17, 2003, 07:13 #2
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What code do you use to create a cookie? Did it still not work after you deleted the cookie manually? Normally you delete a cookie with an emty value and a expire timestamp in the past.
-
Nov 17, 2003, 07:21 #3
- Join Date
- Oct 2002
- Location
- Israel
- Posts
- 270
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Lets say you've created a cookie using the following code:
Code:setcookie("cookie_name","cookie_value",time()+3600,"/","site.com");
Code:setcookie("cookie_name","",time()-3600,"/","site.com");
and any other information that you used after the "time" - if you havn't used any, so don't
use any when you delete the cookie.
In your case, it looks like you'll need to use:
Code:setcookie("cartId","",time()-3600);
- Danny
Bookmarks