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 07:35 AM.
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".
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.
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 !
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
At least 98% of internet users' DNA is identical to that of chimpanzees
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
Bookmarks