I'm having similar problem, and still thinking about some good solutions. first of all let me explain the problem
I'm using Form Authentication in our web application and also using session to save user specific data. problem started when we came to know that session are lossing data if user is being idle for more than session timeout. session timeout set to 60 mins and same is the timeout for Form Authentication. see below.
<sessionState timeout="60" mode="InProc" cookieless="false"/>
<authentication mode="Forms">
<forms loginUrl="Pages/Login.aspx" defaultUrl=".\Pages\Default.aspx" timeout ="60" slidingExpiration ="true">
</forms>
</authentication>
Now the problem is Event viewer is having too many events logged when page is left idle for more than 60 mins and then user try to make any request. it is automatically redirected to login page which is corrected this is how it should work. but at the same time it log (see below.)
vent code: 4005
Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.
Event time: 07/05/2008 10:49:07
Event time (UTC): 07/05/2008 09:49:07
Event ID: ad3cc19382b14007bf8a79ec51d47c66
Event sequence: 4
Event occurrence: 1
Event detail code: 50202
Now here is my understand about above flow. when session and Form Authentication is timeout (it is timing out at the same time in my case.) and when user make any request. Forms Authentication came in to check the validity of the issued ticket. and find it expired and redirect to login. at the same time it create new session. (creating a new session if one already timeout is a buildin feature of IIS.) Now possiablities are:
-- when new session is being created it obiously not have same data which previous session was holding. and user is not redirected to login page some how, and continue to next page with new session that give the effect of session data lost. or may there is someother reason. For this problem I have already put in the code in Global.asax in AcquireRequestState event, which checks every request and session state if user is Authenticated and Session is newly created just forced the user to login page to get all his user specific data again. this will solve my problem of data lost during the user session hopefully.
But my other problem is that event is still being logged in the event log. Beacuse Form Authentication ticket validation is check before session state is being established for the request.
So can some suggest me any good place where i can check my session expiry before Form Authentication ticket validation.