Php Cookies - Accessing From A Different Directory Problemphp cookies
Posted 25 January 2012 - 05:32 AM
My site creates cookies from a page in a directory called ...mysite.com/xbook which works fine - I can create/chnage/access them fine.
The problem I have is when I try to access those cookies from a different directory, in this case, the root directory
Can anyone tell me why this is happening and what to do?
...mysite.com/xbook/create-cookie.php > create cookie call 'name' > cookie created > access cookie 'name' > works fine
...mysite.com/access-cookie.php > access cookie 'name' > returns that cookie does not exists!
Posted 25 January 2012 - 06:08 AM
Cookies can have an extra variable to say which directories they will be available to - the default it the dir from which they were created, for example:
setcookie('cookiename', $cookievalue, $expires); // sets cookie to be available only from the dir where it was created
setcookie('cookiename', $cookievalue, $expires, "/"); // sets cookie to be available throughout site
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users