Forum Moderators: coopster

Message Too Old, No Replies

PHP Cookies

         

aanton05

4:49 am on Nov 29, 2005 (gmt 0)

10+ Year Member



Hi. Could somebody please tell me why in the code snippet below why

$_SESSION['cid'] = $COOKIE['cid'];

is not getting assigned the value of $COOKIE['cid']?

Thanks.

Below is my code:

function cart_add($product_id,$product_qty){
$cart_id = $this->get_cart_id();
if(!$cart_id){
// If no cart id found generate one
$unique_cid = md5(uniqid(rand (),1));
// Set cart id into the cookie
setcookie('cid',$unique_cid,time()+24*3600*60);

// Register session with cart id value
$_SESSION['cid'] = $COOKIE['cid'];

// If person is a member
// modify their profile with
// cart id in the database

if($_SESSION['login']){
$_SESSION['cid'] = $COOKIE['cid'];
@mysql_query("UPDATE members SET cart_id = '{$_SESSION['cid']}' WHERE id = '".$_SESSION['userid']."'");
}
}

daisho

5:00 am on Nov 29, 2005 (gmt 0)

10+ Year Member



$_COOKIE is the super global not $COOKIE.

Daisho.

aanton05

5:13 am on Nov 29, 2005 (gmt 0)

10+ Year Member



Thanks.