Jump to content


Web Site Design, Usability, SEO & Marketing Discussion and Support

  • Announcements

    • cre8pc

      20 Years! Cre8asiteforums 1998 - 2018   01/18/2018

      Cre8asiteforums In Its 20th Year In case you didn't know, Internet Marketing Ninjas released many of the online forums they had acquired, such as WebmasterWorld, SEOChat, several DevShed properties and these forums back to their founders. You will notice a new user interface for Cre8asiteforums, the software was upgraded, and it was moved to a new server.  Founder, Kim Krause Berg, who was retained as forums Admin when the forums were sold, is the hotel manager here, with the help of long-time member, "iamlost" as backup. Kim is shouldering the expenses of keeping the place going, so if you have any inclination towards making a donation or putting up a banner, she is most appreciative of your financial support. 
Sign in to follow this  

Php Cookies - Accessing From A Different Directory Problem

Recommended Posts

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?




...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!



Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this