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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.