2010-12-01 14 views
0

ユーザーロージュ私はクッキーを持っている:ASP.Netクッキーの問題

HttpCookie cookie = new HttpCookie("Username"); 
        cookie.Expires = DateTime.Now.AddDays(1.0); 
        cookie.Value = txtUsername.Text; 
        Response.Cookies.Add(cookie); 

とするとき、再び、ユーザの訪問にはログイン・ページに読み出す:

if (Response.Cookies["Username"] != null) txtUsername.Text = Response.Cookies["Username"].Value; 

しかし、私ログインした後、直接ログアウトすると、クッキーは削除されます。それは、exp-dateも値も保存されていません。

私は間違っていますか?

+0

すべきですか? Firebug for Firefoxのようなブラウザ組み込み開発ツールを使用して、クライアント上のクッキーで何が起こっているかを確認しましたか? –

答えて

6
if (Response.Cookies["Username"] != null) txtUsername.Text = Response.Cookies["Username"].Value 

どのようにこれをテストしている

if (Request.Cookies["Username"] != null) txtUsername.Text = Request.Cookies["Username"].Value