Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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());
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900