K3

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 protected void LoginButton_Click(object sender, EventArgs e)
    {
        username 
= Guid.NewGuid().ToString();
        Response.Write(username);
        FormsAuthenticationTicket ticket 
= new FormsAuthenticationTicket(username, true20);
        
string cookiestr = FormsAuthentication.Encrypt(ticket);
        HttpCookie ck 
= new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
        
if (true)
        {
            ck.Path 
= FormsAuthentication.FormsCookiePath;
        }
        Response.Cookies.Add(ck);
        FormsAuthentication.RedirectFromLoginPage(username, 
false);
    }
    
protected void LogoutButton_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Response.Redirect(
"Default.aspx");
    }
posted on 2008-09-12 10:41  K3  阅读(321)  评论(0编辑  收藏  举报