This example describes the way jquery uses cookies and JSON to simply implement a shopping cart. Share to everyone for your reference, specific as follows:
1, generate a cookie to store the product ID string type
2, add the product ID when the cookie into the array, and check whether it has been included. Does not include regenerating the new array with the JS push.
3, the array into string to store with cookies.
Here's how jquery operates on cookies and JSON
$.cookie ("Cart", "IDs", {expires:-7,path: "/"})//Storage Cookies Save 7 days
if ($.cookie ("cart") ==undefined) {//no use undefined
var cartarr=new Array ();
$.parsejson ($.cookie ("cart"))//convert
to array cartarr.push (ID);//New Arrays
json.stringify (Cartarr);/This seems to be the browser's own. Array into JSON
More interested readers of jquery-related content can view this site: "JQuery Cookie Tips Summary", "jquery table (table) Operation Tips Summary", "jquery drag-and-drop effects and tips summary", "jquery extension Techniques Summary", " jquery Common Classic Effects Summary "jquery animation and special effects usage Summary", "jquery selector usage Summary" and "jquery common Plug-ins and Usage summary"
I hope this article will help you with the jquery program design.