第一:写Cookies
HttpCookie userLession_zhengshur_Cookie = new HttpCookie("lcode");
userLession_zhengshur_Cookie.Value = "chen jian ping";
userName_zhengshu_Cookie.Path = "/";
userLession_zhengshur_Cookie.Path = "/";
//限定有效期
userLession_zhengshur_Cookie.Expires = DateTime.Now.AddDays(1);
userName_zhengshu_Cookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(userLession_zhengshur_Cookie);
Response.Cookies.Add(userName_zhengshu_Cookie);
//Cookies添加
Response.AppendCookie(user_cookies);
//取值
Response.Write(Request.Cookies["uname"].Value);
function Get(){
var cookieString=new String(document.cookie)
var cookieHeader = "userLession="
var beginPosition = cookieString.indexOf(cookieHeader)
if(beginPosition != -1)
{
alert(cookieString.substring(cookieHeader.length,cookieString.indexOf(";")));
}
}
新闻热点
疑难解答