用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,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。