How to set the jQuery cookie for a URL with Fragment?


I am using the jquery cookie plug-in

I saw this reference on how to build a URL with Fragment: AJAX Applications Crawlable

The final url rule looks like this:


(original url should like this: localhost/site/search?_escaped_fragment_key=searchword&page=1)

Each above page has one button, I want to check:

  • If user never clicked, he/she can do the click,
  • If user has clicked, then add class voted for forbidden click again.
  • I want set cookie for 7 days.

My javascript code:

  $(".up").live('click',function() {
    $.cookie('up', 'vote', { expires: 7, path: '/', domain: '' });
    var up = $.cookie('up');
    if (up == 'vote') {

In anycase, the jquery cookie does not work for me. How can I set the jquery cookie for a URL with Fragment?

Fragments are never sent to the server, so you cannot set a cookie for a fragment. You can only set a cookie for the path, and it defaults to the path up to the last forward slash I believe according to the RFC.