Sayed
Sayed

Reputation: 1062

jQuery cookies not working !

I have a big problem, jQuery cookies not working in all browsers.. And I'm using latest jQuery library version 1.4.4

Please help me

Edit:

var mid = $.cookie('mid');
if (mid == '1') {
    $('#something').css('background', '#d3d3d3');
}

Upvotes: 1

Views: 22091

Answers (4)

Rejwanul Reja
Rejwanul Reja

Reputation: 1491

First you need to confirm the html page is in server like localhost or hosted in any server. If you try to implement in index.html in general local directory in your pc, it will not work. Thanks

Upvotes: 2

Kobi
Kobi

Reputation: 138017

Some ideas:

  1. Try checking the error console for errors (on Firefox, Ctrl+Shift+J, or F12 for firebug).
  2. Make sure you the cookie plugin is included in the page properly.

Upvotes: 6

InventMagic
InventMagic

Reputation: 91

I had the Same Problem and the solution was too simple, I was loading jquery.cookie.js before I was loading jquery. As soon as I rearranged the script inclusions the problem went away.

script type="text/javascript" SRC="javascript/jquery-1.5.1.min.js"></script>
script type="text/javascript" SRC="javascript/jquery-ui-1.8.10.custom.min.js"></script>
script type="text/javascript" SRC="javascript/jquery.cookie.js"></script>
script>

Upvotes: 9

OJ.
OJ.

Reputation: 29401

This might sound like a stupid question, but are you sure you have the jQuery cookie plugin included in your markup file? If it's this one, it doesn't come out of the box with jQuery, you have to include it yourself.

Upvotes: 2

Related Questions