1

I'm running this code,

<html>
    <head>
        <title>D</title>
        <script type="text/javascript" src="jQuery.js"></script>
        <script type="text/javascript" src="Cookie.js"></script>
        <script type="text/javascript">
            $(document).ready( function() {
                $.cookie("d", "1") ;
            }) ;
        </script>
    </head>

    <body>
            <script type="text/javascript">
                alert( $.cookie("d") ) ;
            </script>
    </body>
</html>

It's showing '1' on Firefox, IE, but 'null' in chrome. Any idea why? I'm using latest jQuery and cookie plugin from http://plugins.jquery.com/files/jquery.cookie.js.txt

Dewsworld
  • 13,367
  • 23
  • 68
  • 104
  • duplicate : http://stackoverflow.com/questions/335244/why-does-chrome-ignore-local-jquery-cookies – Kai Oct 28 '11 at 06:24

2 Answers2

10

Chrome doesn't support cookies for locals unless you start it with the --enable-file-cookies flag. You can read a discussion about it at here

*Chrome does support cookies if you use the local IP address (127.0.0.1) directly. so in the localhost case, that could be an easier workaround.

Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106
Unknown Coder
  • 1,510
  • 2
  • 28
  • 56
1

The JQuery Cookie does not work in Chrome Browser. So, today after hours of work I found a solution to use javascript Storage API to accomplish this. You can check This Post to know details.

Manoj Kumar
  • 111
  • 3