The code is simple:

setcookie("username",$username,0,$URL);

But it fails to write cookie in Firefox & IE, but works when I'm using Chrome.
I read that cookie is not browser problem since it's sending through header.
But I'm pulling my hair here.

Would someone help me?

    warozzo wrote:

    I read that cookie is not browser problem since it's sending through header.

    And who do you think sends/receives those headers to/from your server? (Hint: It's the browser.)

    What does $URL contain? Have you viewed the HTTP headers between your browser and server to see if the cookie is ever sent back by your browser? How are you testing whether the cookie gets set?

      Well there's one problem - the fourth parameter of [man]setcookie/man expects a path, not a URL.

        Yes. Thank you very much. Now, it works. I hear somewhere someone says, "Read the Fine Manual." 🙂

        But, I'm wondering, why it works in Chrome but not in others?

          Are you saying that even after fixing the URL -> path problem it still doesn't work in any other browser?

          If you're asking why it worked in Chrome before... who knows; apparently the Chrome developers are more forgiving/understanding when the server sends a cookie with invalid/malformed parameters.

            No, it's working in Firefox and IE, now. And Chrome of course.

              Write a Reply...