views:

408

answers:

2

Hi,
Since today I am facing a tricky issue with Google Chrome that I've just updated to v5.
I have a user login process running on my website. Everything works fine on FF 3.6.x and IE 7, but I just can't set any cookie in Google Chrome 5. I'm mentioning 5 because it worked very well before on v4.

My PHP script looks like that:

  $cook = setcookie($cookieName, $value, $expires, '/', '.'.$domain);
  var_dump($cook, isset($_COOKIE[$cookieName]));

I even tried the alternative setrawcookie without any result.

  $cook = setrawcookie($cookieName, $value, $expires, '/', '.'.$domain);
  var_dump($cook, isset($_COOKIE[$cookieName]));

FF 3.6.x and IE7 output:

bool(true) bool(true)

Whereas Chrome v5 outputs:

bool(true) bool(false)



And obviously I see not trace of this cookie in Google Chrome 5. Any idea? =/

Cheers,
Nicolas.

A: 

You can check cookies by entering javascript:alert(document.cookie) into address bar.

Cookie will be sent to server on 2nd request. [browser request(no cookie)]->[server response(set cookie)]...[browser request(cookie, if valid)]->... So you should see the cookie in $_COOKIE by refreshing the testpage.

Also check if your parameters are right. (time in future and domain is your domain)

Imre L
Hi, I set up a test page like that: `setcookie('mycookie', 'value', 1275045629, '/', '.192.168.0.xxx');` and the `javascript:alert(document.cookie)` does only show me the PHPSESSID cookie. Did you try on google chrome 5 yourself?
Nicolas
Remove domain to see if it works. '.192.168.0.xxx' is invalid. You shouldn't add dot to IP addresses.
ZZ Coder
dont prefix IPs with a dot. It's meant for domain names for subdomain purposes.
Imre L
Yeah that's the trick! thanks a LOT :) If I used the IP address it's because the website is under development on one of our server. The strange thing is that all other browsers (and 'old' chrome versions too) do NOT care about that dot.
Nicolas