www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: [RESOLVED] Cookie problem

  1. #16
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    1,101
    Thanks, that's cool... But I'll need some javascript anyway, to get the client's time on his computer. If I do everything with PHP, it will get the server's time, and that's not what I want. I guess two years ago I chose the javascript version to avoid a big mess... I'll have to take a good look at my code, especially at the big cookies stuff I made in javascript, to see if I can make it work by setting the cookie with php.
    I first posted in the PHP forum, because I thought I could maybe specify the place to look for the cookie with $_COOKIE and I didn't find anything regarding path on the $_COOKIE documentation. That would be the easiest, it would avoid modifying lots of pages (the cookie functions are called quite often in different places of the website). It would really save me lots of trouble.
    And for setting the path in the set cookie function, I tried that already. I don't know if I can code it to make it save the cookie on the website's root, since the page is placed on a subdomain. Fang seemed to say it wasn't possible. The other way around would not be that hard, but getting from the subdomain to the domain seems hard to do.
    Last edited by Ness_du_Frat; 09-01-2010 at 08:35 AM.

  2. #17
    Join Date
    Jan 2009
    Posts
    3,346
    Read the link I posted. The issue isn't the reading of the cookie. Is it when you set the cookie. You need to set the domain.

  3. #18
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    1,101
    Yeah, I tried that already, setting the domain to "". I also tried with the path set at "/", then at "". Nothing works. The cookie is still set at blog.domain.com and can't be accessed by my page
    The problem is that the main page is at blog.domain.com, and the page trying to call the cookie is at domain.com. So the cookie works for all the pages at blog.domain.com, but not on the other ones.
    The client did something to the htaccess file, obviously, to move index.php and all the stuff but not the page I'm talking about...
    the direct link to the wp index is something like blog.domain.com/blogname/wp_content/index.php
    and the direct link to the page is www.domain.com/blogname/wp_content/page.php
    If I try blog.domain.com/blogname/wp_content/page.php, it doesn't work. If I try www.domain.com/blogname/wp_content/index.php, it doesn't work. So the two are in different domains... I really don't know what to do. A very big part of me is like "WTF, the client broke the website, that's his fault" and a smaller part is like "this website is on my CV, if somebody visits it and everything is broken, that's bad for me".

  4. #19
    Join Date
    Jan 2009
    Posts
    3,346
    As stated in the other post in the PHP forum you need to use ".domain.com" for the domain in order for root and sub-domains to have access to the cookie.

  5. #20
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    1,101
    That's the first thing I tried and it wasn't working. I tried it again, and as a result, the cookie is still created in blog.domain.com, and the main page doesn't have access to it anymore. Then, I discovered I forgot to add .domain.com in a place. After a bit of tweaking around, trial and error, I made it work ! Thanks criterion9, now it's working like a charm, you're great !

  6. #21
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Quote Originally Posted by criterion9 View Post
    As stated in the other post in the PHP forum you need to use ".domain.com" for the domain in order for root and sub-domains to have access to the cookie.
    Also mentioned here in post #4

  7. #22
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    1,101
    You're right, Fang. My mistake. I did put .domain.com as a domain, but I forgot to change one of them, which was not in the same place, and that's why I thought it wouldn't work, Big thanks to both of you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles