There has been much discussion about a very annoying bug and how it has afflicted the customers at CrystalTech that have sites running on ColdFusion 7. For those of you who don't know what I am talking about, those in the loop know this as "Session is invalid". Anyhow, it has something to do with J2EE sessions getting out of synch with the ColdFusion sessions...
Anyhow, there are solutions out there for use in Application.cfm files, but there aren't any for Application.cfc files. Well, I think I have a solution that works using the onError() method in Application.cfc. I'd be curious to see if this works for anyone else. Let me know.
Well here it is:
<cffunction name="onError" returntype="void" access="public" hint="">
<cfargument name="exception" type="any" required="true" hint=""/>
<cfargument name="eventName" type="string" required="true" hint=""/>
<!--- --->
<cfset var expirationDateTime = "">
<cfset var redirectUrl= "/index.cfm">
<cfif arguments.exception.message IS "Session is invalid" AND
IsDefined("cookie.jsessionid")>
<cfset expirationDateTime = GetHttpTimeString(DateAdd("d", -1, Now()))>
<cfheader statuscode="302" statustext="Moved Temporarily"/>
<cfheader name="location" value="#redirectUrl#"/>
<cfheader name="Set-Cookie"
value="JSESSIONID=;expires=#expirationDateTime#;path=/"/>
</cfif>
</cffuntion>