Does anyone have a piece of javascript code that creates a cookie and stores an array in it? If you also have the code to read through through cookie and delete it, that would be great as well. Thanks!
+2
A:
have a look at: http://plugins.jquery.com/project/cookie
to store an array
$.cookie('COOKIE_NAME', escape(myarray.join(',')), {expires:1234});
to get it back
cookie=unescape($.cookie('COOKIE_NAME'))
myarray=cookie.split(',')
Christian Smorra
2010-08-04 18:21:29
If your data can contain special characters, you should use JSON encode/decode. Otherwise, an entry containing "," will give incorrect decode result.
HoLyVieR
2010-08-04 18:42:15
Okay, thanks. I tried the jquery example above and couldn't get it to work properly. I may just be missing something. You can create cookies while not using a web server correct?
Josh
2010-08-04 21:30:54
Dang. Yes, you need to have a web server for this... Was hoping not to. Thanks.
Josh
2010-08-04 21:34:42
there is no way to create cookies without a webserver josh, if you want to test locally you need to setup a home package like xampp
Christian Smorra
2010-08-05 11:14:44