美文网首页
asp.net删除cookie

asp.net删除cookie

作者: 青木川_ | 来源:发表于2017-12-11 14:43 被阅读3次
    退出

    //删除cookie
    function returnCookie()
    {
    $.ajax({
    type: "post",
    dataType: "text",
    url: "ashx/logo.ashx",
    data: "our=退出",
    success: function (msg)
    {
    if (msg == "True")
    {
    window.location.href = "logo.aspx";
    }
    }
    });
    }
    一般处理程序写
    if (our == "退出")
    {
    if (context.Request.Cookies["user100"] != null && context.Request.Cookies["user100"].Value != "")
    {
    try
    {
    context.Response.Cookies["user100"].Value = null;
    context.Response.Cookies["user100"].Expires = DateTime.Now.AddDays(-1);
    HttpCookie cookie = new HttpCookie("user100", null);
    cookie.Expires = DateTime.Now.AddDays(-10);
    context.Response.Cookies.Add(cookie);
    context.Response.Write("True");
    }
    catch (Exception er)
    {
    throw er;
    }
    }
    }

    相关文章

      网友评论

          本文标题:asp.net删除cookie

          本文链接:https://www.haomeiwen.com/subject/gcmiixtx.html