退出登录,清除Session

 1 protected void Button1_Click(object sender, EventArgs e)
 2    {
 3        if (Session["UserName"!= null)
 4        {
 5            Session.Remove("UserName");
 6            Session.RemoveAll();
 7            Response.Cookies["UserName"].Expires = DateTime.Now;
 8        }

 9        Page.RegisterStartupScript("","<script>window.top.document.location.href='index.aspx';</script>");
10    }
posted on 2009-03-27 09:17  钱途无梁  阅读(1872)  评论(1编辑  收藏  举报