退出登录,清除Session

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

9Page.RegisterStartupScript("","<script>window.top.document.location.href='index.aspx';</script>");
10}

你可能感兴趣的:(session)