码迷,mamicode.com
首页 > 其他好文 > 详细

获取cookie

时间:2018-11-06 21:28:01      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:user   mat   new   use   doc   bsp   return   cape   exp   

getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
if(arr=document.cookie.match(reg)){
return unescape(arr[2]);
}
else {
return null;
}
}
getCookie("username")

获取cookie

标签:user   mat   new   use   doc   bsp   return   cape   exp   

原文地址:https://www.cnblogs.com/xiaoyaoweb/p/9918018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!