js在cookie里存储数组array数据
程序员文章站
2022-05-13 10:00:03
...
js添加、修改、查询、删除cookie
http://happyqing.iteye.com/blog/2289730
js扩展String添加startWith方法,endWith方法
http://happyqing.iteye.com/blog/2289705
js扩展Array添加indexOf方法,remove方法,删除元素
http://happyqing.iteye.com/blog/2289707
数据格式 accountHistory=13100000001|13100000002|13100000003
function setCookieArray(c_name, value, expireTimes){ var cookie = getCookie(c_name); var cookieArr = cookie.split("|"); cookieArr.push(value); cookie = cookieArr.join("|"); if(cookie.endWith("\\|")){ //删除最后的| cookie = cookie.substring(0, cookie.length-1); } setCookie(c_name, cookie, expireTimes); }
JavaScript Array 对象
http://www.w3school.com.cn/jsref/jsref_obj_array.asp