Click here to Skip to main content
14,241,514 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am using the following code in Session_Start() function:

Session_Start() 
{   
  HttpContext context = HttpContext.Current;
  HttpCookieCollection cookies = context.Request.Cookies;
  if (cookies["starttime"] == null)
{
HttpCookie cookie = new HttpCookie("starttime",DateTime.Now.ToString());
cookie.Path = "/";
context.Response.Cookies.Add(cookie);
}
else
{
context.Response.Redirect("~/ErrorPages/SessionExpired.aspx", true);
}
} 


Due to this code users are facing session time out problem. This problem is not consistent so it's difficult to track. Also i am new to ASP.NET. So please provide me the solution for this problem.

Also I have set the session timeout 60 minutes in Web.config file and i am using the windows authentication mode.
Posted
Updated 21-Sep-10 3:33am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

If i am not wrong then this below line is creating issue.

HttpCookie cookie = new HttpCookie("starttime",DateTime.Now.ToString());


So give the Value like
HttpCookie cookie = new HttpCookie("starttime", DateTime.Now.AddMinutes(60).ToString());
   
Comments
mandy1987 21-Sep-10 11:38am
   
thanks for your reply on this problem but this doesn't make any difference i am still facing the same problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100