$("#loginOut").click(function () {
if (confirm("确定要退出登录吗?")) {
$.ajax({
type: "post",
url: "LoginOut.ashx",
success: function (msg) {
alert(msg);
$("#usr-inf1").empty().append("欢迎登录");
//window.location.href = "Default.aspx";
loginBar();
},
error: function (msg) { alert(JSON.stringify(msg)) }
})
}
else {
return;
}
})
LoginOut.ashx文件:
public void ProcessRequest(HttpContext context)
{
HttpResponse Response = context.Response;
Response.Clear();
Response.ContentType = "application/text";
string result_src="退出登录成功";
HttpCookie cookies = context.Request.Cookies["user"];
if (cookies != null)
{
cookies.Expires = DateTime.Now.AddHours(-8);//cookie一开始就是设置8小时的, Response.Cookies.Set(cookies);
}
Response.Write(result_src);
Response.End();
}