1

The Java Script cookie work fine in all major browser but does not work in Chrome.

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    } else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/; domain=.198.XXX.XX.99";
}

Cookies are not set in Chrome.

user13500
  • 3,817
  • 2
  • 26
  • 33

1 Answers1

0

You have to access the page using the IP-address provided under domain and drop the dot before IP, or drop domain all together:

document.cookie = name + "=" + value + expires + ";path=/;domain=198.XXX.XX.99";
                                                                 |
                                   No dot (.) -------------------+

Here I assume XXX.XX is only obfuscation before posting here on Stack Overflow.

Note: As you can not wildcard IP-address in the domain portion of the Cookie, it becomes rather useless.

Chrome does not accept prepending dot to numeric IP address. E.g. FireFox accept either or. For domains it used to be mandatory, but is now optional.


Edit: It is surely worth testing. I always use a BIND etc.+fake domain on local net/or standalones, thus never IP/localhost or the like. (At least last 10+ years.)

But there seems to be varying trouble around using IP/localhost:

Though some of it is dated, do a thorough check or set up a fake domain.

Community
  • 1
  • 1
user13500
  • 3,817
  • 2
  • 26
  • 33