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

  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.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.
Updated 21-Sep-10 3:33am

1 solution

Rate this: bad
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());
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)

Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190612.1 | Last Updated 21 Sep 2010
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

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