Jump to content

Cookies not setting, (not leading to next page)


George Botley

Recommended Posts

Hello,

 

 

It's as subject says.

 

 

Here is the code:

 

 

<? 
//Config
include_once "../../config/config.php";


//Variables
$username = $_POST["username"];
$username = mysql_real_escape_string($username);


$password = $_POST["password"];
$password = md5($password);


//Check for User
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$query = mysql_query($query);


//If user not found
if(mysql_num_rows($query)!="1") {
   echo "No User Found";   
}


//If User Found
else {


   while($row=mysql_fetch_array($query)) {
      $fname = $row["fname"];
      $lname = $row["lname"];
      $userid = $row["id"];
      $admin = $row["admin"];
   }
   
   setcookie("fname", "$fname");
   setcookie("lname", "$lname");
   setcookie("userid", "$userid");
   setcookie("admin", "$admin");
   
   header('Location: ../../../portal/index.php');
   
}


?>

 

 

On the page it forwards to, I write

 

 

print_r($_COOKIE);

 

 

Yet it doesn't show my newly set cookies, yet the above snipped does on the script code above.

 

 

George

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.