I am trying to set a basic cookie that will be used in other scripts that i am writing. I have always been able to set cookies, but for some reason my script is not working now. My browser is already set up to allow sites to set cookies.
here is my code
<?
session_start();
include "_db.connection.php";
$temail = "no_signup";
$pass = "tsr236";
$current_time = date("YmdHis");
$ip = GetHostByName($REMOTE_ADDR);
$nomid = $_COOKIE['nomid'];
if(!isset($nomid)){
include "_db.connection.php";
$sql=mysql_query("INSERT INTO members (email, password, signup_date, ip_address) VALUES ('$temail', '$pass', '$current_time', '$ip')");
$memid = mysql_fetch_object(mysql_query("SELECT member_id FROM members WHERE ip_address='$ip' AND signup_date='$current_time' ORDER BY member_id DESC LIMIT 1"));
mysql_close($db);
}
$nomid=$memid->member_id;
$_SESSION['nomid'] = $nomid;
setcookie("nomid", $nomid, 0);
//header("Location: index.php");
echo $_COOKIE['nomid'];
?>
;
Why is this script not setting the cookie? I can echo the $nomid variable and it shows exactly what is supposed to be set in the cookie. It just does not set. Any help would be greatly appreciated 🙂
Thanks!
Tim