登入時cookie儲存使用者名稱和密碼。
    string username = this.username.Text;
    string password = this.password.Text;

    //向客戶端瀏覽器加入cookie
    HttpCookie hcUserName = new HttpCookie("UName");
    hcUserName.Expires = System.DateTime.Now.AddDays(7);
    hcUserName.Value = HttpUtility.UrlEncode(username);

    HttpCookie hcPassWord = new HttpCookie("UPwd");
    hcPassWord.Expires = System.DateTime.Now.AddDays(7);
    hcPassWord.Value = password;

    Response.Cookies.Add(hcUserName);
    Response.Cookies.Add(hcPassWord);

退出時設定Cookie過期。
    
    Response.Cookies["UName"].Expires = System.DateTime.Now.AddSeconds(-1);//設定過期時間
    Response.Cookies["UPwd"].Expires = System.DateTime.Now.AddSeconds(-1);