Hi all,
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?
Example
...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!
TIA
Php Cookies - Accessing From A Different Directory Problem
Started by hitchhiker, Jan 25 2012 05:32 AM
php cookies
1 reply to this topic
#1
Posted 25 January 2012 - 05:32 AM
#2
Posted 25 January 2012 - 06:08 AM
Solved it
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
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






