Dewsworld
Dewsworld

Reputation: 14033

JQuery Cookie not working on chrome

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

Upvotes: 1

Views: 9780

Answers (3)

Bhabana M
Bhabana M

Reputation: 1

Browser store can be used in stead of Cookies. I like browser local store

Upvotes: 0

Manoj Kumar
Manoj Kumar

Reputation: 111

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.

Upvotes: 1

Unknown Coder
Unknown Coder

Reputation: 1740

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.

Upvotes: 10

Related Questions