用js获取cookie


//获取cookie
function cookie_email(cookie_name)
{
var cookiestr = document.cookie;
if (cookiestr.length > 0) {
var cookie_start = cookiestr.indexOf(cookie_name + "=");
var cookie_end;
if (cookie_start != -1) {
cookie_start = cookie_start + cookie_name.length + 1;
cookie_end = cookiestr.indexOf(";", cookie_start);
if (cookie_end == -1) {
cookie_end = cookiestr.length;
}
var cookie_values = unescape(cookiestr.substring(cookie_start, cookie_end));
if (cookie_values.indexOf("&") > 0) {
var cookie_arry = cookie_values.split("&");//这个就是cookie的所有键值,根据需要返回即可
//var cookie_want_arry = cookie_arry[0].split("=");
//return cookie_want_arry[1];
}
}
else { return false; }
}
else {
window.location.href = "http://www.cnblogs.com";
}
}

用js获取cookie,布布扣,bubuko.com

用js获取cookie

上一篇:JS学习之路


下一篇:Asp.net Form登陆认证的回顾学习