How can you create a Cookie that never expires?

 Posted by Ddd on 1/31/2011 | Category: ASP.NET Interview questions | Views: 21794 | Points: 40
Answer:

It can be created using this coding.


HttpCookie h=new HttpCookie("userinfo");
h.Value="welcome";
//this line is very important
h.Expires=DateTime.MaxValue;
Response.Cookies.Add(h);


//Write this code in a suitable event handler
//eg: Button1_Click


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response