Page 1 of 1
Cookie not setting for all directories
Posted: Sun Jun 22, 2008 4:27 pm
by andym01480
I have a simple remember my login used in a login script for /admin/ directory.
Code: Select all
if($_POST['remember']=='y') setcookie('remember',$data['userlevel'],time()+60*60*24*30,'/');
it is not holding for another directory which relative to the script setting it is ../fpdf/
What have I done wrong?
Re: Cookie not setting for all directories
Posted: Thu Jun 26, 2008 1:59 am
by koen.h
andym01480 wrote:I have a simple remember my login used in a login script for /admin/ directory.
Code: Select all
if($_POST['remember']=='y') setcookie('remember',$data['userlevel'],time()+60*60*24*30,'/');
it is not holding for another directory which relative to the script setting it is ../fpdf/
What have I done wrong?
If the path for the cookie is 'dir/subdirA', your cookie won't be available for 'dir/subdirB' (which is '../fpdf/').
Re: Cookie not setting for all directories
Posted: Thu Jun 26, 2008 2:21 am
by andym01480
That's what I am experiencing. But the manual says...
The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.
So is there a bug in the manual or php?
Re: Cookie not setting for all directories
Posted: Thu Jun 26, 2008 2:00 pm
by koen.h
andym01480 wrote:That's what I am experiencing. But the manual says...
The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.
So is there a bug in the manual or php?
You got me. I now see that the path you have set in the cookie is root. So the cookie should be available in the whole domain. But aren't we mixing server directories and domain paths?
Re: Cookie not setting for all directories
Posted: Thu Jun 26, 2008 2:03 pm
by koen.h
andym01480 wrote:That's what I am experiencing. But the manual says...
The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.
So is there a bug in the manual or php?
You got me. I now see that the path you have set in the cookie is root. So the cookie should be available in the whole domain. But aren't we mixing server directories and domain paths?