Questions tagged [jquery-cookie]

A simple, lightweight jQuery plugin for reading, writing and deleting cookies.

jQuery Cookie is a simple, lightweight jQuery plugin for reading, writing and deleting cookies.

321 questions
109
votes
6 answers

jquery save json data object in cookie

How do I save JSON data in a cookie? My JSON data looks like this $("#ArticlesHolder").data('15', {name:'testname', nr:'4',price:'400'}); $("#ArticlesHolder").data('25', {name:'name2', nr:'1', price:'100'}); $("#ArticlesHolder").data('37',…
Marthin
  • 6,009
  • 14
  • 53
  • 91
94
votes
7 answers

How to delete a cookie using jQuery?

I want to use jQuery to delete cookies; I have tried this: $.cookie('name', '', { expires: -1 }); But when I refresh the page, the cookie is still there: alert('name:' +$.cookie('name')); Why?
user319854
  • 3,650
  • 11
  • 39
  • 44
22
votes
2 answers

How do I store an array of objects in a cookie with jQuery $.cookie()?

I have a list of javascript objects: var people = [ { 'name' : 'Abel', 'age' : 1 }, { 'name' : 'Bella', 'age' : 2 }, { 'name' : 'Chad', 'age' : 3 }, ] I tried to store them in a browser cookie with jQuery $.cookie(): $.cookie("people",…
dangerChihuahua007
  • 18,433
  • 28
  • 104
  • 190
22
votes
3 answers

Create a cookie if (and only if) it doesn't already exist

I want to: Check to see if a cookie with name of "query" exists If yes, then do nothing If no, create a cookie "query" with a value of 1 Note: I am using jQuery 1.4.2 and the jQuery cookie plugin. Does anyone have any suggestions as to how I can…
Sphvn
  • 4,938
  • 7
  • 35
  • 55
21
votes
5 answers

Saving multiple panel's collapsed state using cookies with $.cookie()

I'm trying to determine how I might save a collapsible panel's collapsed state using $.cookie. This question has been helpful so far, but still missing the end solution. Any solutions I have found so far have only saved the last rolled down panel…
Master Yoda
  • 3,966
  • 8
  • 34
  • 67
18
votes
4 answers

How do I set a cookie to expire after 1 minute or 30 seconds in Jquery?

How do i set my cookie to expire after 30 sec or 1 m ? this is my code : $.cookie('username', username, { expires: 14 }); // expires after 14 days
Attila Naghi
  • 2,326
  • 4
  • 29
  • 52
12
votes
1 answer

Using Bootstrap, have alert box remember close action

I am trying to create a Bootstrap alert box that remembers when users click the close button. I guess I need to store that information in a cookie. Ideally that cookie will only last for that current session, and next they return the box will appear…
TinyTiger
  • 814
  • 2
  • 16
  • 33
11
votes
3 answers

Why does jQuery cookie not actually set a cookie?

I am developing an application using jQuery that uses cookies. Right now, it is located at application.html on my PC desktop. However, I cannot store and retrieve a cookie. I had included jquery-1.7.1.min.js, json2.js, and jquery.cookie.js in my…
dangerChihuahua007
  • 18,433
  • 28
  • 104
  • 190
11
votes
3 answers

Is it possible for jQuery cookies to expire like session variables?

I know this question has been asked a thousand times but none of the answers really give me what I'm looking for. I am using jQuery cookie to store some information, but I want them to expire when the browser closes. window.unload is not a viable…
Adam K Dean
  • 7,135
  • 10
  • 43
  • 68
10
votes
2 answers

JQuery cookie extension will set a cookie with a path but will not read it

First, set a cookie: jQuery.cookie('monster', 'big', { path : '/sesame/'}); Next, try to read it: jQuery.cookie('monster'); Firefox tells me that the cookie has indeed been set. The value is big and the path is /sesame/. And yet when I tried to…
Manoj Govindan
  • 64,355
  • 21
  • 123
  • 132
9
votes
4 answers

jquery cookie set value to boolean true

I am using this jquery.cookie plugin and I need to set value to TRUE or NULL/FALSE. I am trying to do it like this: $.cookie('ff', true, { expires: 30, path: '/' }); but it sets the value to string and not boolean. Any ways of fixing this?
Alex
  • 7,089
  • 19
  • 74
  • 141
7
votes
3 answers

Is using the jQuery Cookie plugin a valid way of testing to see if cookies are enabled?

I have a site that we require the user to have enabled JavaScript and cookies before they can login to the site. (The JS part is done and works perfectly.) At the moment, we have been been setting a cookie and then redirect the user to another page…
Darryl Hein
  • 134,677
  • 87
  • 206
  • 257
7
votes
2 answers

How to read the cookie creation date (not expiration)

Is there a way to store in a variable a cookie creation date? I'm using the jquery.cookie plugin. If there is not a way, I'm thinking about store in the cookie, as value, the actual time/date. It could be a solution. Thanks.
6
votes
1 answer

How to close a notification bar with cookies and expiry date from php?

In my previous question I was searching for a way to create a notification message on my WordPress site, when there is a new post published. After a great answer, this is working very well. I can change the settings of how long this message should…
Caspert
  • 3,977
  • 13
  • 44
  • 88
6
votes
4 answers

(jQuery) Save checkbox state on click in cookie

There are a lot of topics regarding this function, nonetheless I can't seem to get it working. I've googled on this specific case and a bunch of links let me here, but strangly enough I can't seem to get them to work. The only thing I did get…
user1913435
  • 83
  • 1
  • 1
  • 3
1
2 3
21 22