Subdirectoried Cookie
Posted: Fri Dec 12, 2003 11:03 am
So I made a very basic set cookie script, which sets a test cookie.
***********setcookie.php************
setcookie($cookie_name, $cookie_value, $cookie_expire, '/');
I then made a cookie test page which tests for the cookie existance and is in the same directory.
***********testcookie.php************
<? print_r($_COOKIE); ?>
testcookie.php works fine and shows that my cookie has been set. So then I copied testcookie.php into a subdirectory and went into that subdirectory and ran it - and my cookie wasn't set in there!
I thought that '/' indicated that the current directory and all subdirectories would have that cookie. Why doesn't my subdirectoried testcookie.php show my cookie?
-----------------------
I then tried putting my subdirectory in instead of '/' as an experiment.
setcookie($cookie_name, $cookie_value, $cookie_expire, $subdirectory);
When I did that, the testcookie.php showed no cookie both in the current directory and the subdirectory. I don't really understand the pathing argument of setcookie() perhaps...?
***********setcookie.php************
setcookie($cookie_name, $cookie_value, $cookie_expire, '/');
I then made a cookie test page which tests for the cookie existance and is in the same directory.
***********testcookie.php************
<? print_r($_COOKIE); ?>
testcookie.php works fine and shows that my cookie has been set. So then I copied testcookie.php into a subdirectory and went into that subdirectory and ran it - and my cookie wasn't set in there!
I thought that '/' indicated that the current directory and all subdirectories would have that cookie. Why doesn't my subdirectoried testcookie.php show my cookie?
-----------------------
I then tried putting my subdirectory in instead of '/' as an experiment.
setcookie($cookie_name, $cookie_value, $cookie_expire, $subdirectory);
When I did that, the testcookie.php showed no cookie both in the current directory and the subdirectory. I don't really understand the pathing argument of setcookie() perhaps...?