We are trying to use the onSessionEnd to remove a cookie that is set in the login.cfm page. This is intended to allow us to know when the session has ended to avoid generating errors when the session variables used within the pages are no longer defined. We would rather send the user to the login.cfm page with a message 'Your session has timed out' instead of generating a generic error message from the Application.cfc onError function.
The code we are using in login.cfm to set the cookie is as follows:
<cfcookie name="sessionEnd" expires="never" value="n">
The code that we are using in the onSessionEnd function in Application.cfc is as follows:
<cffunction name="onSessionEnd" access="public" returnType="void">
<cfargument name="sessionScope" required=True/>
<cfargument name="applicationScope" required=False/>
<cfcookie name="sessionEnd" expires="now" value="#Now()#">
<cfmail to="aschlan@lps.org" from="parentaccount@lps.org" subject="onSessionEnd" type="html">
Session Ended
</cfmail>
</cffunction>
The function seems to run because I do get the email but the cookie is not removed. When I invoke the function manually it sends the email AND removes the cookie. I do not understand why it would work when I manually invoke it but not work when it's run on it's own. Any information would be helpfull at this point.