Hi I am wondering why my cookie is not working in another page. please check if there is a problem: first page: refer.php: link: http://sp724.com/members/refer.php?user=1 code: <?php if(isset($_GET['user']) AND is_numeric($_GET['user']) ) { $userid=$_GET['user']; $in1Month1 = 60 * 60 * 24 * 30 + time(); setcookie('refferer', $userid, $in1Months); if(isset($_COOKIE['refferer'])){ $referer = $_COOKIE['refferer']; echo $referer; } } //header("Location: http://rooyekhat4u.com"); ?> PHP: 2nd page: link: http://www.sp724.com/members/saleconfirmed.php code: <?php if(isset($_COOKIE['refferer'])){ $referer = $_COOKIE['refferer']; echo $referer; } ?> PHP: but the first result is different with the second one
As far as I know script cannot access cookies set in the same script. So this code setcookie('refferer', $userid, $in1Months); if(isset($_COOKIE['refferer'])){ $referer = $_COOKIE['refferer']; echo $referer; } PHP: will not get you value of $_COOKIE['refferer'] you have set by setcookie in line before.