から可能な重複をクッキーを削除する方法:
私はときに、ユーザーのログアウトクッキーを削除したい
Delete cookie on clicking sign outネット
。
は、ここに私のコードです:
if (HttpContext.Current.Request.Cookies["currentUser"] != null)
{
DeleteCookie(HttpContext.Current.Request.Cookies["currentUser"]);
}
public void DeleteCookie(HttpCookie httpCookie)
{
try
{
httpCookie.Value = null;
httpCookie.Expires = DateTime.Now.AddMinutes(-20);
HttpContext.Current.Request.Cookies.Add(httpCookie);
}
catch (Exception ex)
{
throw (ex);
}
}
しかし、それは動作しません。提案はありますか?
私はあなたが 'Value'をクリアすべきではないと信じています。 AFAIK、クッキーの特定方法 –
クッキーの削除はセカンダリクリーンアップに過ぎないことに注意してください。重要な部分は、サーバー側のCookieの値を無効にすることです。 – CodesInChaos