I can not read the Cookie -
$_COOKIE["this_cookie"]
from different folders.
I can read it from the folder where the script is. But not from any other folder.
Here is the script.
<?
header("Pragma: ");
header("Cache-Control: ");
header("Expires: Mon, 26 Jul 1980 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
$username = ($_REQUEST['username']);
$password = ($_REQUEST['password']);
// EDIT HERE TO SUIT YOUR NEEDS
$uname[1] = "admin";
$upass[1] = "admin";
$known_as[1] = "admin user";
$login_page = "login.php";
$success_page = $_SERVER['PHP_SELF'];
$validate_path = "admin/validate.php";
$login_err = '<p><div align="center"><b>Your User Name or Password was incorrect</b></div>';
$empty_err = '<p><div align="center"><b>Please login with your User Name and Password</b></div>';
$chr_err = '<p><div align="center"><b>Please retry</b></div>';
if($username == "" && $password == "" && !isset($_COOKIE["this_cookie"])){
include($login_page);
print($empty_err);
exit();
}
if($username != "" || $password != "" && !isset($_COOKIE["this_cookie"])){
if (preg_match ("/[^a-zA-Z0-9]/", $username.$password)){
include($login_page);
print($chr_err);
exit();
}
}
if (!isset($_COOKIE["this_cookie"]) ){
$user_count = count($uname);
$user_exists = false;
for ($i = 1; $i <= $user_count; $i++) {
if ($uname[$i] == $username && $upass[$i] == $password){
$user_id=$i;
$user_exists = true;
}
}
if(!$user_exists){
include($login_page);
print ($login_err);
exit();
}
$cookie_val=crypt($uname[$user_id]);
setcookie ("login_name", $known_as[$user_id], 0);
setcookie ("this_cookie", $cookie_val, 0);
header("Location: $success_page");
exit();
}
if($REQUEST_URI == $validate_path){
echo "<html>\n<head>\n";
echo "<title>Yor are logged in</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
echo "You are logged in. <a href=\"".$success_page."\">Continue</a>\n";
echo "</body>\n";
echo "</html>\n";
}
?>
any ideas please??
Alex