Page 1 of 1

Cookies not being created?

Posted: Tue Nov 19, 2002 4:26 pm
by Jim
Here's the script that is supposed to create cookies using the input 'user_name' and 'password'.

Code: Select all

<?
include("config.php");

//Validate username/pass against Database
$sql = "SELECT * from IamJim_users where user_name = '$user_name' and password = '$password'";
$query = mysql_query($sql);

$num = mysql_num_rows($query);
echo $num;

	if($num != 1) {
		echo "No such user in our database!  Please <a href="/iamjim/php/login/register.php">register</a> or hit your back button and try again!";
		exit;
		
		} else {
		
		if($num == 1) {
	setcookie("IamJim_user" , $user_name , time() + 3600);
	setcookie("IamJim_pass" , $password , time() + 3600);
	setcookie ("IamJim_user", $password,time()+3600);  
	
	header("Location: http://www.empiregaming.net/iamjim/");
	}
	
}
?>
Am I doing something wrong in creating the cookies?

Posted: Tue Nov 19, 2002 4:41 pm
by volka
setcookie ("IamJim_user", $password,time()+3600);
a mix of the two previous lines?

Posted: Tue Nov 19, 2002 4:45 pm
by Jim
I copied a line from PHP.net and filled in my own information. Just to see if my syntax was incorrect. :) That's what the third input is.

Posted: Tue Nov 19, 2002 6:03 pm
by mydimension
try using $_COOKIE['password'] instead of $password. and like-wise for any other variable you are attempting to pull out of a cookie.