JavaScript 对 cookie的操作

Author : luckyGirl

cookie概述,介绍了cookie的属性优劣势,这一篇以实际代码来展示如何在JavaScript中进行操作,主要操作包括存储,读取,删除,以及测试cookie是否被禁用。 <script type=”text/javascript”> // Cookie 工具类 function Cookie(name){ this.name = name; var allcookies = document.cookie; if(allcookies == “”){ return; } var cookies = allcookies.split(‘;’); var cookie = null; for(var i=0;i<cookies.length;i++){ if(cookies[i].substring(0,name.length+1)==(name+’=’)){ cookie = cookies[i]; break; } } if(cookie == null){ retur[Read More]

standard