Skip to content

jQuery cookie plugin for storing/retrieving JSON

License

GPL-2.0, MIT licenses found

Licenses found

GPL-2.0
GPL-LICENSE.txt
MIT
MIT-LICENSE.txt
Notifications You must be signed in to change notification settings

appendto/jquery-jsoncookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery JSON Cookie

Cookies are the most widely available form of persistent client-side storage. Unfortunately there's no built-in support for storing structured data inside of one. That's where the jsoncookie plugin comes in; this plugin allows you to store any data that can be represented via JSON. This means that you can store objects, arrays, strings, numbers, and booleans and get the data back exactly as you expect. (Standard cookie size limitations of 4K still exist)

Usage

$.cookie( string key, mixed value [, hash options ] )

Stores a value for a given key.

  • key: Identifier for the value being stored.
  • value: The value to store. The value can be anything that can be serialized as JSON.
  • [options]: A set of key/value pairs that relate to settings for storing the value (see Options section below).

 

$.cookie( string key )

Gets a stored value based on the key.

$.cookie()

Gets a hash of all stored values.

Options

  • expires Duration in milliseconds that the cookie should exist.
  • domain Limit which pages can access the cookie based on the (sub)domain. Defaults to the current domain.
  • path Limit which pages can access the cookie based on the path. Defaulst to the current path.
  • secure Boolean. Whether to limit the cookie to only be sent over secure connections.

This plugin requires the JSON object to exist. For support in older browsers, you'll need to include json2.js.

For more information on cookies, see the MDN documentation.

Chrome doesn't support cookies for local files unless you start it with the --enable-file-cookies flag.

About

jQuery cookie plugin for storing/retrieving JSON

Resources

License

GPL-2.0, MIT licenses found

Licenses found

GPL-2.0
GPL-LICENSE.txt
MIT
MIT-LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published