06-14-2011، 06:57 AM
(آخرین تغییر در ارسال: 06-14-2011، 06:58 AM توسط Amin_Mansouri.)
پاک کردن کوکی در asp.net
نقل قول:How-To: Delete a cookie in ASP.NET
Deleting a cookie from ASP.NET is something that trips up a lot of people (myself included when I first started ASP.NET coding). Here’s how:
What confused me originally is that HttpCookieCollection contains a Remove method. This doesn’t remove cookies from the user’s browser. It only removes the cookie entry from the local collection. What you have to do is force the user’s browser to delete the cookie itself. The way to do this is to add an expired cookie: the browser will then clean up the cookie itself.
کد:
void DeleteCookie( HttpContext context, string name )
{
var cookie = context.Request.Cookies[name];
if( cookie != null )
{
cookie.Expires = DateTime.Now.AddYears( -30 );
context.Response.Cookies.Add( cookie );
}
}
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg