I have a question about Authlib 1.92
When I include backend.php in a file one directory
above it, I do not get an array returned when I use
is_logged function after successfully loging in. but
if I put this same file in the same directory as
backend.php it works fine.
THE FOLLOWING DOES NOT WORK always outputs "not logged
in" even if I am.
<?
require("./regdir/backend.php"); file://i used
require("regdir/backend.php") also
$login_check = $authlib->is_logged();
if (!$login_check){
echo "not logged in";
}
else{
echo "logged in";
}
?>
But if I put this file in the same directory as
backend.php with require("backend.php") and i log in
this will output "logged in". Do you have a solution
to this problem, it seems that I can only protect
pages if they are in the same directory as
backend.php. is this true?
Logged In: YES
user_id=392739
This is due to how the cookie is getting set. It is not
set with the path parameter. You will need to modify
backend.php. The login function calls setcookie, but does
not specify the path, so just modify it to include the path
of "/".
setcookie("authlib", "$username:$hash:$id", time()
+3600, "/");
You will also need to add the domain if you are using
multiple hosts and want the cookie to be available. i.e.
www.domain.com and store.domain.com. In this case, you
will want to modify setcookie as follows.
setcookie("authlib", "$username:$hash:$id", time()
+3600, "/", ".domain.com");
Hope this helps.
Jeff