.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Interview Question >> ASP.Net >> Post New Question Subscribe to Interview Questions

In ASP.NET how to destroy a cookie?

Posted By :Jean Paul     Posted Date :May 16, 2011    Points :40   Category :ASP.Net 
We cannot destroy a cookie on user's machine by Cookies.Remove method.

Instead we can set an already expired date for cookie expiration property.

if (this.Response.Cookies["MyCookie"] != null)
HttpCookie cookie = this.Response.Cookies["MyCookie"];
cookie.Expires = DateTime.Now.AddDays(-1);

You can also find related Interview Question to In ASP.NET how to destroy a cookie?  below: 

Maximum Data that can be stored in a cookie?

Maximum 4 KB data can be store in a cookie. (More...)

What is Cookie Munging?

By default, asp.net uses cookies to store session id for the logged in user. But there is an option in every browser to disable cookies. If cookies are disabled, then any website will not be able to create cookies on user's machine.

When cookies are disabled, then session Id is gets appended in the URL and passed to the server. Server decodes it and fulfill the requested page.

Cookie Munging is nothing but how ASP.NET manages session variables without cookies.

Virendra Dugar (More...)

What is persistent and non-persistent cookie?

Persistent Cookies : This can be said as permanent cookies, which gets stored on user's machine. For persistent cookie, one need to set the expiry date.

Non Persistent Cookies : This is Temporary Cookies which get's stored in browser's memory. (More...)

How do you create a permanent cookie?

By setting the time out as infinite (More...)

what is session ,cache, cookie, application memory timeout?


Session timeout: 20 min
Cache timeout: duration we have to specify.
Cookie: for in memory cookie till browser opened
For persistent cookie timeout is till expires property's time .
Application memory timeout: till appdomain exist (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend