#jQuery-SuperCookie
A simple, jQuery plugin for reading, writing and deleting JSON values stored in cookies.
Quick Usage:
-
create - create cookie
-
check - check existance
-
verify - verify cookie value if JSON
-
check_index - verify if index exists in JSON
-
read_values - read cookie values as string
-
read_indexes - read cookie indexes as an array
-
read_JSON - read cookie value as JSON object
-
read_value - read value of index stored in JSON object
-
replace_value - replace value from a specified index stored in JSON object
-
remove_value - remove value and index stored in JSON object
Download the minified version or the development version.
<script src="/path/to/lib/jquery-min.1.8.2.js"></script>
<script src="/path/to/lib/jquery.cookie.js"></script>
<script src="/path/to/lib/json3.min.js"></script>
<script src="/path/to/jquery.SuperCookie.min.js"></script>
- jquey.cookie - by Klaus Hartl
- json3 - by Kit Cambridge
// cookie name: name_of_the_cookie
// cookie values: {name_field_1:"value1",name_field_2:"value2",name_field_3:"value3"}
$.super_cookie().create("name_of_the_cookie",{name_field_1:"value1",name_field_2:"value2"});
See jquey.cookie official page for more options.
// cookie options: {expires: 7,path: "/"}
$.super_cookie({expires: 7,path: "/"}).create("name_of_the_cookie",{name_field_1:"value1",name_field_2:"value2"});
// console.log($.super_cookie().check("name_of_the_cookie"));
$.super_cookie().check("name_of_the_cookie");
// console.log($.super_cookie().verify("name_of_the_cookie"));
$.super_cookie().verify("name_of_the_cookie");
// console.log($.super_cookie().check_index("name_of_the_cookie","value1"));
$.super_cookie().check_index("name_of_the_cookie","value1");
// console.log($.super_cookie().read_values("name_of_the_cookie"));
$.super_cookie().read_values("name_of_the_cookie");
// console.log($.super_cookie().read_indexes("name_of_the_cookie"));
$.super_cookie().read_indexes("name_of_the_cookie");
// console.log($.super_cookie().read_JSON("name_of_the_cookie"));
$.super_cookie().read_JSON("name_of_the_cookie");
// $.super_cookie().create("name_of_the_cookie",{name_field_1:"value1",name_field_2:"value2"});
// console.log($.super_cookie().read_value("name_of_the_cookie","name_field_1"));
$.super_cookie().read_value("name_of_the_cookie","name_of_the_index");
// $.super_cookie().create("name_of_the_cookie",{name_field_1:"value1",name_field_2:"value2"});
// console.log($.super_cookie().replace_value("name_of_the_cookie","name_field_1","new_value"));
$.super_cookie().replace_value("name_of_the_cookie","name_of_the_index","new_value");
// $.super_cookie().create("name_of_the_cookie",{name_field_1:"value1",name_field_2:"value2"});
// console.log($.super_cookie().add_value("name_of_the_cookie","name_field_3","value3"));
$.super_cookie().add_value("name_of_the_cookie","name_field_3","value3");
// $.super_cookie().create("name_of_the_cookie",{name_field_1:"value1",name_field_2:"value2"});
// console.log($.super_cookie().remove_value("name_of_the_cookie","name_field_1"));
$.super_cookie().remove_value("name_of_the_cookie","name_field_1"));
- Source hosted at GitHub
- Report issues, questions, feature requests on GitHub Issues
-
jquery.SuperCookie - Tantau Horia
-
jquey.cookie - Klaus Hartl
-
json3 - Kit Cambridge