User authentication with cookie. I can't see what's wrong
Posted: Thu Aug 14, 2003 4:29 pm
This is the script used in the file that verifies the user-pass and it seems to be alright.
When I add the following script as an include to restrict access to the next page, the cookie in the first script doesn't seem to be set.
I've been working on this all day and can't figure out how to fix the problem.
Code: Select all
<?
if($username && $password) {
mysql_connect("localhost","root","") or die ("Whoops");
$password = ($password);
$sql = "select * from utilisateurs where username='$username'";
$r = mysql_db_query("micmacs",$sql);
if(!mysql_num_rows($r))
header("Location: authentification.php");
$user = mysql_fetch_array($r);
if($userї"password"] == $password) {
$password = ($password);
setcookie("micmacs_login","$username $password");
$msg = "<meta http-equiv="Refresh" content="0;url=./soumettre.php">";
}else{
header("Location: authentification.php");
}
}
if ($msg) echo $msg;
?>Code: Select all
<?
if(!$_COOKIEї'micmacs_login'])
header("Location: authentification.php");
$known=$micmacs_login;
if($known) {
mysql_connect("localhost","root","") or die ("Whoops");
$user = explode("","$known");
$sql = "select * from utilisateurs where username='$userї0]'";
$r = mysql_db_query("micmacs",$sql);
if(!mysql_num_rows($r)) {
header("Location: authentification.php");
}
$chkusr = mysql_fetch_array($r);
if(($userї1]) != $chkusrї1])
header("Location: authentification.php");
}
?>