I’m having a hard time with cookies i have a basic test to see if cookies are enabled and if they are to create cookies if not then to create a session.
now the test to see if the cookies are enabled works fine how ever i can’t create the cookies
what happens is when a user login it checks to see if there registered and if the password that was inputted is correct to the one they registered with basic authentication if they are who they say they are then it creates the cookie with the userID all of this is done before any other header information is set however it doesn’t create the cookies
[code=php]
if(!isset($red) && !isset($_COOKIE[‘test’])) {
setcookie(“test”,”true”,0,”/”,”.purelyme.co.cc”);
$red=1;
header(‘location:’.$_SERVER[‘PHP_SELF’].”);
}
if (isset($_POST[‘login’])) {
$action = “Signing in Please Wait. <br/> <img src=’images/loader.gif’ />”;
if(isset($_POST[’email’])){
$sql = “SELECT * FROM `Users` WHERE `Email` ='”.$_POST[’email’].”‘”;
$results = mysql_query($sql, $conn) or trigger_error(“SQL”, E_USER_ERROR);
$newArray = mysql_fetch_array($results);
if ($newArray[‘Activated’] != “N”) {
if ($newArray[‘Password’] == $_POST[‘password’]) {
if(isset($_COOKIE[‘test’])){
setcookie(“user”,$newArray[‘ID’],time()+3600*24*30,”/”,”.purelyme.co.cc”);
setcookie(“type”,$newArray[‘ProfileType’],time()+3600*24*30,”/”,”.purelyme.co.cc”);
if(isset($_POST[‘remember’])){
setcookie(“remember”,”checked”,time()+3600*24*30,”/”,”.purelyme.co.cc”);
setcookie(“pass”,$newArray[‘Password’],time()+3600*24*30,”/”,”.purelyme.co.cc”);
}
}else{
session_start();
$_SESSION[‘id’] = $newArray[‘ID’];
$_SESSION[‘ProfileType’] = $newArray[‘ProfileType’];
}
}else{
$response = “Wrong Email / Password.”;
$success = “N”;
}
}else{
$response = “Your account has not been Activated yet Please Check you Email.”;
$activated = “N”;
}
}
}