http://stilbuero.de Klaus Hartl – Stilbüro - Klaus Hartl


Jump to: Search, Additional Information.


Cookie Plugin for jQuery

I contributed a cookie plugin for jQuery yesterday. You can get it from the (Subversion) repository:

svn://jquery.com/plugins

Or get it here. A few simple examples of how to use it:

$.cookie('the_cookie'); // get cookie
$.cookie('the_cookie', 'the_value'); // set cookie
$.cookie('the_cookie', 'the_value', { expires: 7 }); // set cookie with an expiration date seven days in the future
$.cookie('the_cookie', '', { expires: -1 }); // delete cookie

You’ll find the complete documentation inline.

Update

Ralf Engelschall suggested on the jQuery mailing list, that it is more intuitive to delete a cookie by passing null as value:

$.cookie('the_cookie', null); // delete cookie

I agree and updated the plugin accordingly. The old syntax for deleting still works of course.

165 Comments

Comments feed

  1. Where can I download it. I found it listed only on visualjquery.com.
    Thanks.

    Comment by Jan, November 1st, 2006 at 10:45 pm

  2. Author Comment

    You can get it from SVN here or simply checkout jQuery plugins from svn://jquery.com/plugins.

    Comment by Klaus, November 1st, 2006 at 11:17 pm

  3. Comment by Jan, November 2nd, 2006 at 12:12 am

  4. It really is useful plugin, but not listed on main jQuery site.
    Are there any reasons?
    Let people know about it!

    Comment by Xander., November 3rd, 2006 at 2:36 am

  5. Author Comment

    Done. That totally slipped out of my mind. Thanks!

    Comment by Klaus, November 3rd, 2006 at 8:57 am

  6. Works great. Thanks.

    Comment by Dubiousd, November 18th, 2006 at 2:03 am

  7. great work man, thanks!

    Comment by klevo, December 1st, 2006 at 8:47 pm

  8. Hey Klaus,

    Great plugin, I love it. I’m using it to store settings for a Javascript puzzle game I’m working on.

    Works fine in IE7 and Firefox, but IE Take a look here

    Comment by Dave, December 10th, 2006 at 5:35 am

  9. Hi Klaus, My comment was truncated. Take a look at my website listed above.

    Comment by Dave, December 10th, 2006 at 5:37 am

  10. What I want to do on my blog, is every few hours take the oldest post and move it to the
    front of the queue, all automatically. Anyone know if there is a plugin that can do this or
    a simple way to set up another plugin to do this (use my own feed perhaps)?
    Thanks.

    Comment by Billy, December 12th, 2006 at 9:25 pm

  11. Hey Klaus,

    It works fine in IE 6 etc… My version of IE 5, 5.5, and 6 apparently don’t actually save cookies fine (because they are hacked versions to allow you to run all three versions on the same computer).

    My apologies.

    Dave

    Comment by Dave, December 24th, 2006 at 2:58 am

  12. [...] Cookies für jQuery [...]

    Pingback by netgra.de Blog » » JQuery - Plugintipps, January 28th, 2007 at 5:35 pm

  13. Im dont fully understand, how can i use this to for example remember a div´s position and the re-set it when i reload the page?..

    Comment by Mikael, February 18th, 2007 at 7:40 pm

  14. [...] Right, what a discovery. Anyway for all of you who did not get this far before, here is a little jquery plug in  for creating and retreating [...]

    Pingback by jquery ViewState challange, going web 2.0 « DavidPirek Blog | Web 2.0, AJAX, jquery, prototype, February 28th, 2007 at 10:39 pm

  15. Works great. Thanks :D

    Comment by Jeff, March 8th, 2007 at 8:47 pm

  16. Anyone having trouble with cookies saving in IE6?

    Comment by Eric, March 23rd, 2007 at 6:08 pm

  17. LOL, sorry, false alarm, IE Developer tools was disabling all cookies. ;)

    Comment by Eric, March 23rd, 2007 at 6:10 pm

  18. Hi,
    Can you also publish compressed file.
    Cheers,
    Kush

    Comment by kush, March 26th, 2007 at 8:26 am

  19. Author Comment

    Kush, you find that in the repository now.

    Comment by Klaus, March 26th, 2007 at 10:41 am

  20. Good work. It’s interesting to use only one function, which gets or sets cookie depends on numbers of arguments. But I don’t find especial sense to bind up such functionality into jQuery.

    By the way, toGMTString() method is deprecated by the toUTCString().

    Comment by Eugene Janusov, March 31st, 2007 at 11:49 pm

  21. Author Comment

    Eugene, thanks, I’ve changed the plugin to use toUTCString. Of course there’s absolutely no need to bind such functionality into jQuery, but I think it is nicer to have that in a namespace instead of using global functions for example. It is also much easier to build your own jQuery distribution with this as plugin.

    Comment by Klaus, April 2nd, 2007 at 9:49 am

  22. Hi Klaus,
    I’m’ wondering if you can help me enjoy this plugin even more:
    1) is is possible to loop through cookies once created. E.g. I’d have thought something like $.cookie.each(function() { but it doesn’t seem to work
    2) the documentation explains how to find the value of a cookie if you know the name – $.cookie(’the_cookie’) – but is there a way to find the name of a cookie if I know the value?

    Thanks very much.

    Tim

    Comment by Tim Reader, April 19th, 2007 at 9:59 am

  23. Author Comment

    Tim,

    loop through cookies and find by value (untested):

    $.each(document.cookie.split(';'), function(i, cookie) {
        var c = $.trim(cookie), name = c.split('=')[0], value = c.split('=')[1];
        if (value == 'whatever') {
            alert('The name is: ' + name);
        }
    });

    Comment by Klaus, April 21st, 2007 at 10:30 am

  24. Hey Klaus,

    That loop through the cookies works really well. Just a little typo, though — the last line is missing the closing parenthesis. Should be });

    Comment by Karl, April 22nd, 2007 at 8:43 pm

  25. Author Comment

    Thanks for the catch, Karl, and for testing :-)

    Fixed it.

    Comment by Klaus, April 22nd, 2007 at 10:07 pm

  26. Hi Klaus,

    Will the expires parameter accept a conditional statement? If so, can you give an example?

    Thanks,
    Adam

    Comment by Adam, April 25th, 2007 at 6:36 pm

  27. Author Comment

    Adam – no it doesn’t (yet). It would have to take a function that gets evaluated. Sounds useful to me… I think I’m going to add that. Not right now though, no time.

    Comment by Klaus, April 25th, 2007 at 6:58 pm

  28. Klaus,
    Thanks a million for the cookie-by-value loop – it does exactly what I needed.
    T

    Comment by Tim Reader, April 26th, 2007 at 1:13 pm

  29. [...] jQuery Cookie [...]

    Pingback by 10 Must have jquery plugins and extensions – Interaction Design Blog, May 3rd, 2007 at 8:27 am

  30. The Jquery site is down and I cannot get this plugin anywhere – why not have a download from your site?

    Comment by Denis, May 7th, 2007 at 1:53 pm

  31. Klaus, can you allow download of this nice plugin from your site please. JQuery’s site still having problems(
    Have a good day.
    Thanks alot.

    Comment by javascript programmer, May 9th, 2007 at 1:32 pm

  32. Hello! Thank you for your work on this awesome plugin, I’m having a hard time downloading it though. Do you care to repost the link to the download site? Thanks!

    Comment by Jacob, May 9th, 2007 at 3:03 pm

  33. Author Comment

    The jQuery site had some troubles lately and all the code was moved to Google Code now. Download the cookie plugin here.

    Comment by Klaus, May 9th, 2007 at 11:26 pm

  34. Hi, thank’s for your great plugin, i want to store the last 5 pages visited for an user in a cookie… it’s possible? Can you help me?
    PD: do you accept a donative (paypal)
    greetings from Chile

    Comment by Sebastian, May 26th, 2007 at 3:16 pm

  35. I may have missed the obvious, but how do we set the units of expiration,
    say for example to have the cookie expire in 4 hours?

    Comment by Stan, May 31st, 2007 at 2:09 pm

  36. Author Comment

    In that case you have to pass a date object with its date set to 4 hours in the future.

    Comment by Klaus, May 31st, 2007 at 8:31 pm

  37. [...] Klaus Hartl – Stilbüro : Cookie Plugin for jQuery [...]

    Pingback by Diigo Diary 06/01/2007 « Benx Blog, June 2nd, 2007 at 2:31 am

  38. Hi, thank’s for your great plugin, i want to store the last 5 pages visited for an user in a cookie… it’s possible? Can you help me?
    PD: do you accept a donative (paypal)
    greetings from Chile

    Comment by Orlando, June 2nd, 2007 at 4:44 am

  39. (greetings from san francisco)

    here is a quick script for saving the last five (or more) pages visited. it can probably be improved (to run automatically, to save time-on-each-page, etc), but it works.

    
    function page_tracker() {
    	// how many pages do we want to remember?
    	var count = 5; // # of pages to remember
    	var delim = "|"; // delimiter for pages in cookie
    
    	// get the previous cookie (if any), split it into an array
    	var visited = ($.cookie("page_tracker") || "").split(delim);
    	// add the current page
    	visited.push(location.href);
    	// remove the oldest location(s), down to our limit
    	if (visited.length > count) {
    		visited = visited.slice(visited.length - count);
    	}
    	// set the new cookie
    	$.cookie("page_tracker", visited.join(delim));
    	return visited;
    }
    
    var pages_visited = page_tracker();
    

    Comment by oliver langan, June 19th, 2007 at 5:57 am

  40. Thank’s works fine!

    Comment by Orlando, June 24th, 2007 at 8:54 pm

  41. [...] questo punto scaricate questo plugin qui: serve ad aggiungere a jQuery il controllo dei cookie, ed è richiesto da Fontsizer. Installate [...]

    Pingback by a tempo perso… » Font-resizer in Drupal, June 29th, 2007 at 11:05 am

  42. [...] Cookie plugin [...]

    Pingback by IPO - Initial Public Offering » Blog Archive » 30 Mar 2007, July 3rd, 2007 at 2:03 am

  43. [...] Cookie plugin [...]

    Pingback by IPO - Initial Public Offering » Blog Archive » 18 Sep 2006, July 3rd, 2007 at 9:46 am

  44. HELP!! Please.
    im trying to get a shopping cart to work using Jquery drag and drop, an interface product, but the cart doesnt save page to page.

    Finally found a jquery cookie action! Thank God for you Klaus, but im having trouble saving the items passed into the cart… tell me to go learn javascript if you like, as i know this may not be the place for this sort of request, but this is what i have.

    $('#cartProducts')
    .append('' + productName + 'removeqty: 1price: £' + productPrice + '')
    .append('')
    .find('div.productCart:last')
    .fadeIn(400)
    .find('a')
    .bind(
    'click',

    How would i use the cookie to then save that info and relay it onto subsequent pages??? Any pointers would be gratefully recieved!

    Comment by Ian, July 4th, 2007 at 3:40 pm

  45. ok all the html was stripped from that, sorry…

    Comment by Ian, July 4th, 2007 at 3:54 pm

  46. Hi Klaus,
    I’m terrible with JS, but I’m trying anyway. I use your cookie plugin on a WP theme and it works. But the thing is, for the time being, it keeps the cookie for each page.
    What I would like it to give me, is only one cookie for the whole blog. How can I do that?
    Thanks.

    Comment by alakhnor, July 16th, 2007 at 6:20 am

  47. Author Comment

    You need to set the appropriate cookie attributes, in your case the path:

    $.cookie('name', 'value', { path: '/' });

    Which options are available is completely documented in the source.

    Comment by Klaus, July 16th, 2007 at 10:41 am

  48. Thanks for your answer. I had tried this option but with ” instead of with ‘/’. My bad…

    Comment by alakhnor, July 16th, 2007 at 12:32 pm

  49. It doesn’t work. Firefox still saves a different cookie for each page. :(

    Comment by alakhnor, July 16th, 2007 at 6:19 pm

  50. Thanks. Very useful. I used it to show/hide a portion of the site and using your plug in the site remembers the view they prefer. Good job.

    Comment by Jeff, July 18th, 2007 at 7:11 pm

  51. I am new to JS, and trying to build a basic session management system.

    I am trying to run the cookie example, and it gives the value of the cookie as ‘the_value’. I am looking to extract the exact value of the cookie and not just ‘the_value’. Please help.

    Also, would it be possible for you to point me to usable code samples, where I can build a basic framework for authentication and then allows users to build their profiles etc.

    Thanks

    Aziz

    $(document).ready(function(){
    //$.cookie(’the_cookie’); // get cookie
    //$.cookie(’the_cookie’, ‘the_value’); // set cookie

    $.cookie(’the_cookie’, ‘the_value’, { expires: 7, path:’/'}); // set cookie with an expiration date seven days in the future

    alert($.cookie(’the_value’));

    $.each(document.cookie.split(’;'), function(i, cookie) {
    var c = $.trim(cookie), name = c.split(’=')[0], value = c.split(’=')[1]
    // if (value == null) {
    alert(’The name is: ‘ + value);
    // }
    });

    //$.cookie(’the_cookie’, ”, { expires: -1 }); // delete cookie
    });

    Comment by Aziz, July 27th, 2007 at 8:11 am

  52. Pingback by Nawak! le blog de Super Chinois » Blog Archive » CSSR 2007 j'arrive!, August 5th, 2007 at 1:17 am

  53. Hay, how do i get the expiration time of the cookie?

    Comment by KEvin, August 10th, 2007 at 3:33 pm

  54. [...] looking for a solution and couldn’t really find a easy one to use, and nothing for jQuery but cookie which can only store a single value in cookies. Ajaxian revealed that CookieJar: JSON Cookies by [...]

    Pingback by jQuery cookieJar : jDempster.com, August 11th, 2007 at 9:16 pm

  55. [...] cookie – Used by cookieJar [...]

    Pingback by jQuery Tablesorter Cookie Widget : jDempster.com, August 13th, 2007 at 4:34 pm

  56. question about retrieving the values in a cookie. I’m getting the cookie created and I can see the values are in it. I have a form that I’m using the cookie to store the values and then I want to put the values on a printable form for the user to print out. I can see the cookie’s value see in quotes:
    “name1%3Dtest%26address1%3D123%2520street%26city1%3D%26state1%3D%26zipcode1%3D%26phone1%3D%26phone2%3D%26fax%3D%26email1%3D%26amount%3D%26date%3D%26question1%3Dtest%26question2%3D%26question3%3D%26question4%3D%26question5%3D”

    so this has the label field name (name1) and “test” is the value, label field name (address1) and the value “123 street”, etc…. as you can see the other values are blank. How do I retrieve the values to put on the form to print?

    thanks for your help. This may be an easy question since I haven’t used javascript much – but am learning. thanks again!

    Comment by Tree Peterson, August 29th, 2007 at 5:49 pm

  57. @Tree Peterson: You’re essentially storing a serialized object inside the cookie.

    var cookieData = decodeURIComponent($.cookie(’formData’));
    //decodeURIComponent() turns the %’s into characters
    var nameValPairs = cookieData.split(’&’); //an array of ‘name=value’
    var formData = {}; //init object (hash)
    var namVal; //good practice to declare all vars
    for (var i = nameValPairs.length; –i >= 0; ) {
    namVal = nameValPairs[i].split(’=');
    formData[namVal[0]] = namVal[1];
    }
    //formData['nameOfField'] now contains that field’s data!

    Pyro

    Comment by Pyrolupus, August 30th, 2007 at 8:28 pm

  58. [...] jquery.cookie.jsについてさらに詳しく知りたい方はこちら Cookie Plugin for jQuery [...]

    Pingback by javascriptライブラリjQueryでcookieを超簡単に扱う方法 : 4GALAXYのメモ, September 5th, 2007 at 1:20 pm

  59. Hi Klaus,

    Your TreeView plugin works great.
    I’m still new to js and jquery. I wanted to ask about how to use the cookie plugin. Do I need to write a script segment and instantiate a cookie and its attributes?

    Thanks.
    Pol

    Comment by pol, September 24th, 2007 at 5:45 pm

  60. [...] Cookie Plugin for jQuery:http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/ [...]

    Pingback by 利用 jQuery 的 cookie 插件,实现对 cookies 的便捷操作 « Ross Wan’s World!, September 26th, 2007 at 7:28 am

  61. If anyone is having problems using this to delete a cookie, keep in mind that you have to use the same path and domain used when the cookie was set. In other words, if the cookie was set using this:

    $.cookie("myCookie", "cookie value", {path: "/"});

    it cannot be deleted using this:

    $.cookie("myCookie", null);

    In this case, it must be deleted using this:

    $.cookie("myCookie", null, {path: "/"});

    Hope this helps anyone who is debugging weird cookie issues.

    Comment by itqou, October 6th, 2007 at 3:54 pm

  62. Below code Alerts ‘null’ in ie6 and safari. Win FF and IE7 are fine. What am I doing wrong?

    code:
    $.cookie(’the_cookie’, ‘the_value’);
    var theCookie = $.cookie(’the_cookie’);
    alert(theCookie);

    Comment by Paul, October 10th, 2007 at 7:16 pm

  63. Hi All!

    How do I check if a cookie with the name ‘filter’ exists?

    Comment by Arjan, October 23rd, 2007 at 1:44 pm

  64. Author Comment

    If no cookie is found with the given name the function returns null, thus:

    if ($.cookie('filter')) { /* do something */ }

    Comment by Klaus, October 23rd, 2007 at 3:16 pm

  65. @itqou: Thank you. You saved me some frustration.

    @Klaus: Thanks for a great plugin. You may want to make a note of itquo’s comment in your documentation.

    Comment by ravidew, October 23rd, 2007 at 5:23 pm

  66. [...] Klaus’ Cookie plugin for jQuery is great, but it has what I consider to be a bug: By default, when you go to save a cookie, there is no default path specified. This caused confusion for me because, when I read a cookie, it was retrieved just find, but when I went to update that same cookie, the changes didn’t “stick.” I’ve updated the source code to make this functionality work. [...]

    Pingback by What Works for Me » Klaus’ jQuery Cookie plugin branch, October 25th, 2007 at 4:21 pm

  67. @Ravidew, @Itqou:

    I had the same problem. As a result, I’ve updated this plugin by making the default path “/”.

    You can download my branch of this plugin here

    Comment by SeanG, October 25th, 2007 at 4:36 pm

  68. My environment is a PC with Tomcat and IE6 both resident. I am trying to write a JavaScript to determine if cookies are enabled, and if not, show a message saying that cookie are required.

    First I disable cookies in IE6 (Tools->Internet Options, Privacy, Advanced, check ‘Override automatic cookie handling’, select radio buttons for First-Party Cookies ‘block’ and Third-Party Cookies ‘block’.)
    Now I want to write a JavaScript test to see if cookies are enabled or disabled. So I use:

    $j.cookie('testcookiesenabled', null);
    $j.cookie('testcookiesenabled', 'enabled');
    if ($j.cookie('testcookiesenabled')) {
    alert("Cookies enabled");
    alert("Cookie: "+$j.cookie('testcookiesenabled'));
    } else {
    alert("Cookies disabled");
    addErrorMessage("To use this site, please enable cookies");
    }

    However, even though I have disabled cookies in IE6, I still get the alert for “Cookies enabled.” Furthermore, the next alert shows the value I set in the cookie, ‘enabled’, so it’s clear that the cookie was set, even though I disabled cookies.
    Does anyone see what I am doing wrong?

    Comment by David Barker, October 29th, 2007 at 9:39 pm

  69. I found my issue. It turns out that when IE6 is retrieving http requests from localhost, the intranet settings to not apply.
    To bypass this, go to Tools->Internet Options, Security tab, select Local Intranet, then Sites. Uncheck both the ‘Include all local (intranet) sites not listed in other zones’ and ‘Include all sites that bypass the pwoxy server.’ Then block the cookies using Internet Options, Privacy, Advanced, Check ‘Override automatic cookie handling’ and choose ‘block’ for both First-Party and Third-Party sites.

    Now cookies are truly blocked.

    Comment by David Barker, October 29th, 2007 at 10:14 pm

  70. [...] Cookie Plugin [...]

    Pingback by Learning jQuery, a book review | SKFox.com, November 3rd, 2007 at 4:10 am

  71. Great plugin. Thanks Klaus.

    Comment by Amha, November 10th, 2007 at 12:17 am

  72. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 240 plugins jquery : sastgroup.com, November 21st, 2007 at 4:14 pm

  73. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by chinatian » jQuery插件超级多, December 6th, 2007 at 3:31 pm

  74. Klaus, could you tell me how to recall a cookie that has a certain domain set in its options? I set it with

    $.cookie('the_cookie', 'jasper', { domain: 'www.example.com' });

    But then I can seem to recall it with something like:

    $.cookie('the_cookie')
    -or-
    $.cookie('the_cookie', '', { domain: 'www.example.com' });

    Am I doing something wrong or this sort of functionality not present in this plugin?

    Comment by Jack Jennings, December 10th, 2007 at 10:51 pm

  75. Author Comment

    Are you trying to set a cross-site cookie? That won’t work…

    Comment by Klaus, December 11th, 2007 at 9:08 am

  76. Your guestbook is example of middle-class guestbooks. Congratulation! Ill show your site and guestbook to my friends.d

    Comment by Bush, December 15th, 2007 at 12:02 am

  77. [...] http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/ by Klaus Hartl 提供方便方法操作cookie [...]

    Pingback by CodeRobots ’s Blog » Blog Archive » jquery插件整理, December 17th, 2007 at 3:26 am

  78. [...] 50) Cookie Plugin for jQuery [...]

    Pingback by 50+ Amazing Jquery Examples- Part1, December 20th, 2007 at 2:57 pm

  79. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by Enjoy what you have! » Blog Archive » 强烈推荐:240多个jQuery插件, December 27th, 2007 at 3:38 am

  80. Hey Klaus,

    könntest mal bei Gelegenheit das Plugin auf http://plugins.jquery.com/ hochladen. Im Moment findet man da nichts nützliches unter “Cookie”.

    Comment by Jörn, December 31st, 2007 at 3:20 am

  81. [...] Cookie Plugin for jQuery. [...]

    Pingback by Diversos Links para desenvoledores de javascript | Blog do teo, January 1st, 2008 at 12:35 pm

  82. @itqou – Thanks a bunch. Your comment on deleting cookies using the same path and domain used when the cookie was set saved me loads of frustration.

    @Klaus – Thanks for a great plugin.

    Comment by Casey, January 4th, 2008 at 12:32 am

  83. Hello, I’m a bit new to JS and Jquery. Sorry for my silly Question.
    My wish is to enable or disable the rating possibility. If the user has rated the item, I will save the itemID and the value of it in to the cookie. Now I need to check if this itemID has a value (been rated) and disable the rating of it (or remove the rate button). How is this possible?
    Thanks for your answers.

    Comment by thebrain, January 9th, 2008 at 10:58 am

  84. [...] social bookmarking icons.jQuery serverCookieJar.jQuery autoSave.jQuery Puffer.jQuery iFrame Plugin.Cookie Plugin for jQuery.jQuery Spy – awesome plugin.Effect Delay Trick.jQuick – a quick tag creator for [...]

    Pingback by Jquery的N个插件 » NeiLyi.cn -尼尔易, January 15th, 2008 at 9:36 am

  85. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 强烈推荐:240多个jQuery插件, January 25th, 2008 at 12:35 pm

  86. Comment by Klaus, January 26th, 2008 at 7:43 pm

  87. [...] 49) Select box manipulation 50) Cookie Plugin for jQuery [...]

    Pingback by Ajax Araçları : vBMaster.Org Seo Yarışması, February 7th, 2008 at 1:11 pm

  88. Can i save the cookie of Draggable Droppables And Selectables ?

    Comment by Anivox, February 9th, 2008 at 4:54 pm

  89. Author Comment

    Anivox, what exactly do you want to save how?

    Comment by Klaus, February 9th, 2008 at 7:29 pm

  90. Hi Klaus,

    I’m using your cookie plugin, but having trouble getting it to work. I have 3 tabs, but when I refresh, it returns to the first tab each time instead of staying on the tab before the refresh. Here’s a snippet of my code:

    …var tab_to_select = $(’#tab_’ + $.cookie(’last_selected_tab’));
    if (tab_to_select.length == 1)
    {
    tab_to_select.click();
    }
    else
    {
    // Select first tab
    $(’#cont-nav #nav li’).slice(0,1).click();
    }
    });

    var show_tab = function()
    {
    var clicked_tab = $(this);
    var tab_id = clicked_tab.attr(’id’).substring(4);
    var tab_title = clicked_tab.text();
    $.cookie(’last_selected_tab’, tab_id, {expires: 7});
    $(’#cont-nav #nav li’).removeClass(’active’);
    clicked_tab.addClass(’active’);
    current_tab_id = tab_id;

    Comment by Darren, February 11th, 2008 at 1:24 pm

  91. Any help would be greatly appreciated. I hope the snippet helps you see what’s going on. Thanks in advance, Klaus.

    Regards,

    Darren

    Comment by Darren, February 11th, 2008 at 1:25 pm

  92. Update:

    I’ve fixed it :-) I changed ’last_selected_tab’ to ‘clicked_tab’ and hey presto, it worked. Maybe this will help someone else in the future.


    var tab_to_select = $(’#tab_’ + $.cookie(’clicked_tab’));

    var show_tab = function()
    {
    var clicked_tab = $(this);
    var tab_id = clicked_tab.attr(’id’).substring(4);
    var tab_title = clicked_tab.text();
    $.cookie(’clicked_tab’, tab_id, {expires: 7});
    $(’#cont-nav #nav li’).removeClass(’active’);
    clicked_tab.addClass(’active’);
    current_tab_id = tab_id;

    Thanks again,

    Darren.

    Comment by Darren, February 11th, 2008 at 1:52 pm

  93. [...] viditelnost bloku do cookie pomocí jQuery pluginu Cookie (tlačítko musí mít identifikátor). Kód by šlo vylepšit výběrem togglpárů, u kterých [...]

    Pingback by Můj jQuery togglovací skript hledá finišátora | Kahi’s mindprint, February 12th, 2008 at 4:53 pm

  94. # jquery.cookie.js
    # jquery.cookie.min.js
    # jquery.cookie.pack.js
    # jquery.cookie.zip

    What’s a different the 4 files ?

    Thanks.

    Comment by l2aelba, February 12th, 2008 at 7:30 pm

  95. Author Comment

    The zip file contains the others, which are differently packed to decrease file size. You may want to have a look into the source and at their file size. Other than that, the first three are the same (functionality-wise).

    Comment by Klaus, February 12th, 2008 at 8:04 pm

  96. It’s my second day of using jquery and thought it’s great, but i’m still a newbiee in this topic, could you write whole code of using cookie to remeber last active tab? I’m trying to do something like igoogle div – drag n drop some div and save position in cookie, but it’s a long way for me to do that. If anyone cold help me write this I will be very appreciate.

    Pual

    Comment by Paul, February 18th, 2008 at 9:51 pm

  97. Good plugin, short on code too. Exactly what I was looking for, so thanks!

    @Paul: Do to that… when a user clicks a tab, set the cookie. When the page loads in the future, read the cookie, and set the active tab depending on the cookie value. Good luck!

    Comment by mark, February 19th, 2008 at 8:51 am

  98. Author Comment

    @Paul, @Mark You don’t really have to that manually. If you want to use Tabs with cookies just include the cookie plugin and set the cookie option. Please refer to the documentation.

    Comment by Klaus, February 19th, 2008 at 10:14 am

  99. [...] about using standard JavaScript to set and read cookies over at Quirksmode. We can use jQuery with Klaus Hartl’s cookie plugin to streamline the process of creating and reading cookies. Furthermore, the plugin simplifies the [...]

    Pingback by Cookies With jQuery - Designing Collapsible Layouts » ShopDev Website Design Blog, February 19th, 2008 at 2:32 pm

  100. Thanks Klaus, I’ve read this topic and in fact there is an option in tab( {cookie: expires: 7} ) but i’m trying to use cookie plugin for drag and drop div, so, when i put a div into some place,close browser and next – open it, the div should still displaying in the same place. Could you help me do that? Thanks for reply to previous message.

    Comment by Paul, February 20th, 2008 at 7:09 pm

  101. [...] 49) Select box manipulation 50) Cookie Plugin for jQuery [...]

    Pingback by Recursos y Tutoriales » Blog Archive » 50 fantasticos ejemplos de Ajax, February 27th, 2008 at 12:41 pm

  102. Hi i am new in jQuery, can you adapt this script to jcookie for me? Thanks!
    Script

    $(document).ready(
    function () {
    $(’div.recebeDrag’).Sortable(
    {
    accept : ‘moduletable’,
    helperclass : ‘dragAjuda’,
    activeclass : ‘dragAtivo’,
    hoverclass : ‘dragHover’,
    handle : ‘h3′,
    opacity : 0.7,
    onChange : function()
    {
    },
    onStart : function()
    {
    $.iAutoscroller.start(this, document.getElementsByTagName(’body’));
    },
    onStop : function()
    {
    $.iAutoscroller.stop();
    }
    }
    );
    }
    );

    Comment by Ramon, March 3rd, 2008 at 10:04 pm

  103. Does anyone know where I can find a Drag & Drop Shopping Cart with a cookie script, Ajax or PHP would be great.

    Thanks for the help…

    Comment by enfopedia, March 13th, 2008 at 7:59 am

  104. [...] social bookmarking icons jQuery serverCookieJar jQuery autoSave jQuery Puffer jQuery iFrame Plugin Cookie Plugin for jQuery jQuery Spy – awesome plugin Effect Delay Trick jQuick – a quick tag creator for jQuery Metaobjects [...]

    Pingback by 百变贝贝 » 上百个让你事半功倍的jquery插件, March 20th, 2008 at 2:31 am

  105. very good, man

    Comment by pig23, April 3rd, 2008 at 9:16 am

  106. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 240 adet jquery ekelntisi - Volkan Şentürk, April 9th, 2008 at 12:06 pm

  107. Good work!

    One question I have is does the plugin handle cookie sub-keys? The ASP response.cookie method allows the storage of cookies under one key

    response.cookie (”SubKey”) (”Value1″)
    response.cookie (”SubKey”) (”Value2″)

    Rather than have to parse all of this it would be fantastic if your plugin intrinsically handled this.

    Comment by Remy, April 11th, 2008 at 11:19 am

  108. [...] jQuery Cookie [...]

    Pingback by 10 Must have jquery plugins and extensions - The Frontend, April 14th, 2008 at 4:05 pm

  109. very nice plugin. i had the same headache with it as Dave with the “standalone” version of IE6, it is good to know this works in normals IE6.

    Comment by taro uma, April 15th, 2008 at 2:52 pm

  110. Hello, at first, thanks for your work man!

    But, i’m having a problem setting an cookie for root-path!
    I’m setting a cookie like this!

    $.cookie('font_size', fontSize, { path: '/', domain: 'localhost', } );

    It sets a cookie for my root-path, but only if the call comes from a root-path document, if the call comes from a non-root-path document it will be set to the document path. E.g.:
    localhost->path: ‘/’
    localhost/cms/services = path: ‘/cms/’

    But i just need the cookie for the root-path!

    Is this a bug or am i doing sth. wrong?!

    Comment by Dennis Winter, April 20th, 2008 at 11:05 pm

  111. Ok, job done!
    My problem is solved!
    Here’s the code

    $.cookie('font_size', fontSize, { path: "/" } );

    I just had to change the inverted comma!

    Regards, Dennis

    Comment by Dennis Winter, April 22nd, 2008 at 3:39 am

  112. So simple yet so useful. Thank you a lot!

    Comment by KTamas, April 28th, 2008 at 11:29 am

  113. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by jQuery插件集合.(240) | Sapling soliloquize, April 28th, 2008 at 6:11 pm

  114. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 强烈推荐:240多个jQuery插件 - 胡言乱语, May 3rd, 2008 at 6:46 am

  115. [...] There are numerous ways to handle cookies on the web, but as we like to around here, let’s harness the awesome powers of jQuery. First, we’ll need to include the jQuery library on our page as well as the very nice cookie plugin: [...]

    Pingback by Redirecting to a Splash Page ( …but only once! ) with Cookies - CSS-Tricks, May 13th, 2008 at 2:46 pm

  116. [...] Cookie Plugin for jQuery [...]

    Pingback by » 1000 ressources pour le développement web et WordPress : la grosse grosse liste « css4design : des css pour votre design html, May 16th, 2008 at 1:38 pm

  117. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 240 plugins jquery | Computer and Technoloy News, May 17th, 2008 at 8:27 am

  118. [...] Jquery Cookie Plugin [...]

    Pingback by ForumKral.Org » Blog Archive » Tekerleği Yeniden Keşfetmeyin, May 27th, 2008 at 10:54 pm

  119. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 翟鹏的博客 » 240个JQuery插件, May 28th, 2008 at 11:01 am

  120. [...] (50) Cookie Plugin for jQuery [...]

    Pingback by 50多个强大的jQuery插件应用实例 | CodeLog, June 6th, 2008 at 9:57 am

  121. Thanks itqou. I was going nutz figuring that out. Klaus, could this be added to some documentation? Its not as clear as one may think.

    Comment by Joe, June 10th, 2008 at 7:43 pm

  122. Hi, how do you save many values separated or splitted in the cookie file? I have to save the item ids in to one cookie file splitted in many values. (like: CookieName: Id1,Id2,Id3) etc. Thanks for your answers.

    Comment by theBrain, June 11th, 2008 at 2:25 pm

  123. [...] jQuery でクッキーを扱うのを下記サイトを参考にやってみました。 javascriptライブラリjQueryでcookieを超簡単に扱う方法 : 4GALAXYのメモ Klaus Hartl – Stilbüro : Cookie Plugin for jQuery [...]

    Pingback by jQuery でクッキーを扱う方法 | Sun Limited Mt., June 11th, 2008 at 11:44 pm

  124. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for [...]

    Pingback by 键盘人生 - 强烈推荐:240多个jQuery插件, June 14th, 2008 at 4:09 pm

  125. can anyone direct me to some simple idot proof documentation for using the jquery plugin. What needs to replace (’the_cookie’) and what needs to be added in (’the_value’)

    Comment by indianabones, June 20th, 2008 at 9:57 pm

  126. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 经典240多个jQuery插件 | 喜羊羊与懒羊羊的窝, June 28th, 2008 at 5:31 am

  127. Unfortunately, this cookie script appears to suffer from a severe bug. I found that it creates multiple copies of the same cookie, rather than changing the original cookie value. I guess this may be because the script lacks a default, domain-wide path setting.

    Regardless of the reason, it caused my site-wide settings to change from page to page. Now, this could be because I should have specified a path; nevertheless, the script is harmful when used “out the box”.

    I reverted to using the quirksmode cookie script, and the problem vanished.

    To be honest, I can’t see the advantage of using Klaus’s script. Both scripts are only a few lines of code, but PPK’s (quirksmode) script works flawlessly whereas Klaus’s is buggy (at least for a naive user, such as I). The syntax for PPK’s script is actually shorter.

    Unless you’re obsessed by the dollar sign — $.cookie(”fanboy”, “jQuery syntax is so cool I have to use it all the time”) — I recommend you stick to the old quirksmode script.

    Sorry Klaus. A+ for effort, but your script broke my website.

    Comment by Mike Hopley, June 29th, 2008 at 1:23 pm

  128. Author Comment

    Yeah, I broke your website…

    Comment by Klaus, June 29th, 2008 at 8:57 pm

  129. [...] Cookie Plugin for jQuery. [...]

    Pingback by Hidden Pixels - JQuery Examples, June 30th, 2008 at 11:52 am

  130. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by jQueryTips » รวมฮิต jQuery Plugins มากกว่า 200 รายการ, July 1st, 2008 at 7:33 pm

  131. Thanks! Here’s how we’re using it along with simplemodal to minimize the intrusiveness of our interstitial/lightbox/splash page/donate request thing:

    if ($.cookie('appeal')) {
    //do nothing: they already saw the appeal
    } else {
    $(document).ready(function () {
    $.cookie('appeal', 'Shown_lightbox_summer_08', { expires: 1, path: '/' });
    $('#elementId').modal();
    });
    };

    Comment by amanda, July 1st, 2008 at 11:29 pm

  132. Yeah, I broke your website…

    I take it you don’t believe me, then? Or perhaps you think I’m an idiot who can’t type his javascript right?

    Suit yourself. You’re welcome to ignore my bug report; I’m only trying to help.

    Yes, your script DID break my website. It’s a simple test: after replacing your script with PPK’s, the cookie settings worked again. I changed nothing else: just the cookie script.

    Comment by Mike Hopley, July 2nd, 2008 at 10:45 am

  133. Author Comment

    Mike, first of all it was your comment that had an aggressive tone. Second, it is pretty well documented that the path is not set automatically and I had my reasons to make it like that (I simply decided to not alter a browsers default behavior). Third, I couldn’t believe that a simple, but well written script would actually break the intarwebs. Feel free to use PPK’s script, you can be pretty sure that his scripts are very well done. But instead of ranting here you could also just have added the path to your scripts.

    In jQuery world we’re indeed obsessed with the dollar sign – which is just an alias for jQuery. I simply use it as a namespace to not pollute the global one and also because for a jQuery user it is most intuitive to find helper methods in this namespace (like $.ajax etc.).

    Comment by Klaus, July 2nd, 2008 at 11:40 am

  134. [...] Cookies A super easy way to manage cookies the jQuery way. [...]

    Pingback by Must have jQuery plugins [July 2008] | SKFox, July 12th, 2008 at 12:58 am

  135. Hello!! This is a very useful plug-in for jquery. But i have a problem beacuse I am new with jQuery and I never used cookies :/

    So what I wont to do is to store in the cookie the size of a DIV, that can be maked larger or smaller by the user, the cookie, muust store the new size each time the user clicks on the button larger/smaller and each time upadate the value, and when the page reloads, to get out from the cookie te last value of the DIV and make it big/smaller as the value into the cookie.

    Here is my code

    /////////////////////////////////////////////////////////////////////////////

    EX4.b

    $(document).ready(function(){

    {
    $(’div.button’).click(function(){

    var $cookie_name = “savedSize_pgz”;
    var $speech= $(’div.speech’);
    var currentSize= $speech.css(’width’);

    if($.cookie($cookie_name)) {
    var $getSize = $.cookie($cookie_name);

    var num= parseFloat(currentSize, 10);
    var unit = currentSize.slice(-2);
    if(this.id==’switcher-large’){
    num *=1.1;}
    else if(this.id== ’switcher-small’){
    num /=1.1;}

    var totalSize=$getSize+num+unit;

    $speech.css(’width’, num+unit );

    $.cookie($cookie_name, totalSize);
    }
    else{

    var $getSize2 =$.cookie($cookie_name, totalSize);

    $speech.css(’width’, $getSize2);
    }

    });//fine div button
    } //fine if

    });//fine principale

    $(document).ready(function() {
    $(’#switcher-large’).hover(function() {
    $(’#switcher-large’).addClass(’hover’);
    }, function() {
    $(’#switcher-large’).removeClass(’hover’);
    });
    });

    $(document).ready(function() {
    $(’#switcher-small’).hover(function() {
    $(’#switcher-small’).addClass(’hover’);
    }, function() {
    $(’#switcher-small’).removeClass(’hover’);
    });
    });

    .hidden{
    width:auto;
    height:auto;
    display:none;
    }

    .selected{
    font-weight:bold;}

    body.large .chapter {
    font-size:1.6em}

    body.narrow .chapter {
    width:400px;}

    #switcher {
    background-color:#DDDDDD;
    border:1px solid #000000;
    float:right;
    font-size:0.9em;
    margin:10px;
    padding:10px;
    }

    #switcher .button {
    cursor:pointer;
    text-shadow:#333333;

    background-color:#FFFFFF;
    border-color:#888888 rgb(68, 68, 68) rgb(68, 68, 68) rgb(136, 136, 136);
    border-style:solid;
    border-width:3px;
    float:left;
    margin:10px;
    padding:10px;
    text-align:center;
    width:100px;
    }

    #switcher .hover{
    background-color:#afa;}

    .speech{
    background-color:#E7E7E7;
    }

    Width switcher
    Largeer
    Smaller

    Fourscore and seven years ago our fathers broutght forth on this conitinent new nation,
    conceived in liberty, and dedicated to the propoisition that all men are created equal. palle..funziona!!!

    PROVA

    /////////////////////////////////////////////////////////////////////////////

    Hope someone could help, tnx!!!

    Comment by Andrea, July 19th, 2008 at 3:28 am

  136. I have some cookie opening issues in IE6, but only on certain PC’s.. Here is my openCookie code, let me know if you see anything wrong. My email is davidnels [a-t] gmail dot com.

    Thanks everyone. What an awesome script. :-)

    function getCookie(name)
    {
    var dc = document.cookie;
    var prefix = name + “=”;
    var begin = dc.indexOf(”; ” + prefix);
    if (begin == -1)
    {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    }
    else
    {
    begin += 2;
    }
    var end = document.cookie.indexOf(”;”, begin);
    if (end == -1)
    {
    end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
    }

    Comment by David Nelson, July 22nd, 2008 at 2:15 am

  137. @Mike

    Wow, naive and ignorant. You need to calm down, man.

    Comment by Adam, July 22nd, 2008 at 6:06 pm

  138. Klaus, this is a great script. I’ve decided to revisit it, to solve a problem I just cannot seem to find the silver bullet for across the internet.

    I am working on an intranet, which has a front page, containing various draggable panels. Essentially, a 3 column layout, with X number of panels that can be maximised, minimised, as well as moved from one column to another.

    Although this works, I cannot seem to get the layout to be saved to a cookie. I know that the layout can be serialised into a single cookie variable, but how to expand it out again.

    I’ve noticed other users across various websites and forums having this issue in one way or another, without any cast iron solution being published.

    Perhaps yourself or one of your visitors can point me in the right direction. This issue has bugged me since March this year, it would be nice to solve it once and for all. Thanks in advance!

    Comment by Stephen Scott, July 30th, 2008 at 1:24 pm

  139. Hi Klaus!
    Sehr geiles Ding. Wir haben das im Kimai drin und es is einfach nur cool. Danke – super Arbeit!
    LG, Torsten

    Comment by Torsten Höltge, July 30th, 2008 at 8:46 pm

  140. Heya,

    Have you got any complete newbie guide? Never worked with cookies before and would like to ask if you could post a minor example that saves the current shown pharagraph of two.

    $(”a#menu”).hover(function () {
    $(”p.inner, p.foot-inner”).toggle(”slide”, {}, 1000);
    });

    Html build:
    Something 1
    Something 2

    This matches Something 1
    This matches Something 1

    Now how can I add a cookie so that when I hover over the
    so that it saves the current hovered pharagraph.

    Best Regards

    Comment by Kasper B, August 5th, 2008 at 7:13 pm

  141. [...] Cookie Plugin for jQuery [...]

    Pingback by Unobtrusive jQuery slide toggle with cookies | ifoh designs, August 26th, 2008 at 9:56 pm

  142. Hey! The plugin is very cool and easy to use but I’ve got a little question: I’ve a lot of divs which can be minimized and maximized and they all have different id’s. Is it possible to get the id name from each div, put it into a cookie, so you can remember which box was minimized and which not?

    Comment by BroOf, September 1st, 2008 at 3:30 pm

  143. Is there a way to set cookies that expire at the end of the session? Is there an example on a site somewhere for setting the cookie in hours or minutes?

    Comment by mari, September 4th, 2008 at 4:56 pm

  144. Author Comment

    @Mari Set a session cookie by omitting the expires option. Set expiration in hours or minutes by passing a Date object to the expires option (both is supported, the number of days or a Date object), for example create a Date (which then is “now”) and add 1 hour.

    Comment by Klaus, September 5th, 2008 at 11:55 am

  145. [...] the jQuery cookie plugin by Klaus Hartl [...]

    Pingback by Bramme.net » A slider on cookies for jQuery newbies, September 6th, 2008 at 11:26 am

  146. [...] 49) Select box manipulation  50) Cookie Plugin for jQuery  [...]

    Pingback by [转]50+ Amazing Jquery Examples- Part1 | Idea-Design, September 10th, 2008 at 5:14 am

  147. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 200+ jQuery插件 | 浮世失焦, September 23rd, 2008 at 5:21 am

  148. [...] bookmarking icons. jQuery serverCookieJar. jQuery autoSave. jQuery Puffer. jQuery iFrame Plugin. Cookie Plugin for jQuery. jQuery Spy – awesome plugin. Effect Delay Trick. jQuick – a quick tag creator for jQuery. [...]

    Pingback by 多个jquery效果演示效果示例 - 虾米碗糕|十里地后院, September 29th, 2008 at 8:36 pm

  149. I’ve written a simple bookmarklet, with using of your plugin. Here’s part of code:

    jQuery.cookie(’xb_qnote_’+qNoteID, qNoteElm.attr(’value’), { expires: 60 });

    Despite I’ve clearly defined that I’d like the cookie to expire in 60 days, Firefox 3 still says:

    Expires: at end of session

    How can I create longer cookies?…

    Comment by Vladimir, September 30th, 2008 at 4:21 pm

  150. I am trying to find out if you want the cookie to NEVER expire or do they after an X amount of time anyway, if you do not set a expire date.

    Thanks,

    Ryan

    Great plugin by the way! Nice job. Thank you for sharing it with us

    Comment by Ryan Coughlin, October 1st, 2008 at 1:23 am

  151. Author Comment

    @Vladimir, looks good to me, can’t really tell what is going wrong. Not sure if you can set cookies after loading the bookmarklet on any page. Have you checked the standard way (document.cookie = ...) just to make sure my plugin is causing this?

    Comment by Klaus, October 1st, 2008 at 10:47 am

  152. Author Comment

    @Ryan, if you den’t set an expiration date you get a session cookie. There’s nothing like an option that says “never expire”, I suggest simply setting the date to a few years in the future, that should be sufficient.

    Comment by Klaus, October 1st, 2008 at 10:49 am

  153. [...] my opinion. Luckily, jQuery has a rather active community behind it, and a nice man by the name of Klaus Hartl has released a jQuery cookie plugin. All we need to do is include the link to the plugin in the head of our document, underneath our [...]

    Pingback by jQuery-Based Popout Ad: Part 3 - CSSnewbie, October 2nd, 2008 at 3:18 am

  154. [...] It requires 3 other plugins to work: – jQuery UI Core – jQuery Easing plugin – jQuery Cookie plugin [...]

    Pingback by Scroll Follow: jQuery Plugin To Scroll Objects | bloground.ro - Blogging resources, WordPress themes and plugins for your development, October 16th, 2008 at 8:35 pm

  155. [...] * UI Core * Slider * Klaus Hartl’s Cookie plugin [...]

    Pingback by 用jQuery UI控制字体大小 | Heartnn's Blog, December 19th, 2008 at 3:24 pm

  156. [...] my opinion. Luckily, jQuery has a rather active community behind it, and a nice man by the name of Klaus Hartl has released a jQuery cookie plugin. All we need to do is include the link to the plugin in the head of our document, underneath our [...]

    Pingback by jQuery-Based Popout Ad: Part 3 | Castup, December 29th, 2008 at 3:49 pm

  157. [...] – jQuery UI Core – jQuery Easing plugin – jQuery Cookie plugin [...]

    Pingback by Scroll Objects using Scroll Follow - A jQuery Plugin | Greepit.com - A Handsome Design Blog, January 7th, 2009 at 9:51 pm

  158. [...] jQuery’s Cookie plugin is also needed to save the state between sessions. The plugin can be found here [...]

    Pingback by Collapse/Expand a HTML element made easy with jQuery « ProgAdv, January 13th, 2009 at 10:18 am

  159. [...] rumgespielt und einen FontSizeSwitcher geschraubt…. wer’s braucht… jQuery(latest) und jQueryCookiePlugin sind notwendig… haveFun, Sven [...]

    Pingback by Example: jQuery FontSizeSwitcher - AJAX (Asynchronous JavaScripting and XML) Forum, January 14th, 2009 at 3:56 pm

  160. [...] Inside the document.ready function first it will check whether any cookie saved for theme or not. If it is available it will take the theme information from the cookie. You can check the documentation about jQuery cookie in detail can be find here. [...]

    Pingback by How to make colour scheme for your website using JQuery and CSS | Sunil's blog, January 17th, 2009 at 3:12 pm

  161. [...] weiteren Infos zum Plugin findet man in dem Post Cookie Plugin for jQuery von Klaus [...]

    Pingback by Cookies mit jQuery lesen, schreiben und löschen - n a s u m i, March 5th, 2009 at 12:23 pm

  162. [...] jQuery’s Cookie plugin is also needed to save the state between sessions. The plugin can be found here [...]

    Pingback by jCollapser plugin to support multiple collapse elements on one page. « ProgAdv, March 5th, 2009 at 3:39 pm

  163. [...] tolle jQuery-Plugin jquery.cookie.js geschrieben hat. Die Originalseite von Klaus Hartl findet man hier und auf der jQuery [...]

    Pingback by Cookies: Danke SPON und danke Klaus Hartl!, May 3rd, 2009 at 2:40 pm

  164. [...] order to set a cookie we use Klaus Hartl’s cookie plugin. Download the plugin and load it in your header like the other .js [...]

    Pingback by the simple guide to jQuery - Day 3 | making tech simple, June 23rd, 2009 at 7:40 pm

  165. [...] is a simple example of this technique that makes use of both jQuery, and a very nice, very simple, jQuery Cookie Plugin. This plugin makes cookie manipulation as easy as $.cookie(’name’,'val’), which is about as easy as [...]

    Pingback by Techwave » Blog Archive » jQuery Example – Using cookies to save draft information, July 1st, 2009 at 4:47 am



Klaus Hartl – Stilbüro is powered by WordPress, jQuery, XHTML, CSS and me.