Jump to content

Cookie problem, very frustrating...


trecool999

Recommended Posts

Hi guys.

 

I have a few years of experience behind me in PHP, MySQL and other languages but there is this one cookie problem I can't get my head around.

If you need it, my website is here: http://web-share.org.uk/

Every time I set a cookie, I know it is there because I can check what cookies are set in Firefox. The problem I've been having is that I can't get PHP to recognise it whenever I come back! Every time I visit my site it tells me that no cookie existed, even though I know damn well it has been set because Firefox tells me it has!

 

Please help! If you need the code, I probably won't be able to give it to you as it is set in many different files (It's a template, source, index and functions based website because I'm making a CMS).

 

*UPDATE*: Whenever I click another menu item after closing the browser and opening again, then it tells me there was a cookie... WTF!?

Link to comment
Share on other sites

From php.net:

 

Common Pitfalls:

   [*] Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

 

 

You're probably checking on the same page you're setting the cookie.

 

Orio.

Link to comment
Share on other sites

From php.net:

 

Common Pitfalls:

    [*] Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

 

Nope. I log in, which sets the cookie, then close the browser, load up web-share.org.uk and then navigate to another page, which only then displays the cookie info I ask it to.

 

 

You're probably checking on the same page you're setting the cookie.

 

Orio.

Link to comment
Share on other sites

Because to me it sounds like you are setting the cookie on one domain, and by using a absolute path in your links, you are switching domains.  Try it with relative path just to see if the cookie works.

 

If not, post the code where you set the cookie along with the page name, and post the code where you check the cookie and that page name.

Link to comment
Share on other sites

I'm not really setting it with the URL included.

I'm just doing a straight-forward setcookie().

Either way, it's called the same thing ($_COOKIE['WebShareCookie']) and Firefox sees it as the same cookie.

I'm going to make this easier for myself (if this is possible):

How can I save the session id to a cookie and then load the same session using the id the cookie has?

Link to comment
Share on other sites

You are if you don't tell it otherwise.

 

You are not considering any of the advice given, so I'll leave you with someone else to help you.

 

I'm not really setting it with the URL included.

I'm just doing a straight-forward setcookie().

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.