js读写cookie

//JS操作cookies方法!
//写cookies
function setCookie(name,value)
{
var Days = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
//读取cookies
function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)) return unescape(arr[2]);
else return null;
}
//删除cookies
function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

最新文章

  1. Protobuf使用规范分享
  2. url 编码(percentcode 百分号编码)(转载)
  3. 【转】cloudera新增用户权限配置
  4. linux安装IPython四种方法
  5. winform 加密 解密 分类: WinForm 2014-05-16 15:05 400人阅读 评论(0) 收藏
  6. DB2中coalesce函数的应用
  7. huffman压缩解压文件【代码】
  8. sqlite的几种访问方法
  9. mysql表空间加密 keyring encryption
  10. WebService发布到IIS
  11. java判断字符串中是否包含中文 过滤中文
  12. 停止一个java的线程执行
  13. 尼康G镜头与D镜头的差别
  14. 使用spring提供的ReflectionUtils简化项目中反射代码的复杂性
  15. Java并发编程里的volatile。Java内存模型核CPU内存架构的对应关系
  16. BZOJ 2763 飞行路线(分层图最短路)题解
  17. Log4J 配置文件模板及代码说明
  18. 点击button触发onclick事件判空后依旧自动跳转
  19. face++ API接口调用
  20. Educational Codeforces Round 56 (Rated for Div. 2) E(1093E) Intersection of Permutations (树套树,pb_ds)

热门文章

  1. Selenium和PhantomJS
  2. ssm中的注解
  3. 别被调查汇总郁闷到——有Excel呢!
  4. SpringCloud微服务实战——搭建企业级开发框架(三十四):SpringCloud + Docker + k8s实现微服务集群打包部署-Maven打包配置
  5. CF667A Pouring Rain 题解
  6. CF177A1/A2 Good Matrix Elements 题解
  7. 【LeetCode】Integer to English Words 解题报告
  8. 【九度OJ】题目1175:打牌 解题报告
  9. 【LeetCode】137. Single Number II 解题报告(Python)
  10. 【LeetCode】852. Peak Index in a Mountain Array 解题报告(Python)