Skip to main content
Known Participant
February 21, 2012
Question

OnRequestStart doesn't always run on request start?!?

  • February 21, 2012
  • 2 replies
  • 2437 views

I have an application.cfc file in my root directory with the following line:

<cffunction name="onRequestStart">

     <cfif NOT IsDefined("Session.PortalPermissions")>

          <cfset Session.PortalPermissions = 0>

     </cfif>

</cffunction>

however i occasionally receive this error report which is emailed to me.  The error is never generated from an included template, not the application.cfc file itself:

Element PORTALPERMISSIONS is undefined in SESSION.

Template: C:\Inetpub\mysite\secure\utilities\tinymce\index.cfm

I'm wondering how it's possible to receive thie error message if the onRequestStart method is called before my template that uses the Session.PortalPermission.

Thanks!

    This topic has been closed for replies.

    2 replies

    Inspiring
    February 21, 2012

    Is there any other Application.cfc or Application.cfm on the ancestor path between the file being requested which is generating the error, and the Application.cfc in the root?

    --

    Adam

    Owainnorth
    Inspiring
    February 21, 2012

    It always runs, but it doesn't run *first*. First it runs any code at the top of Application.cfc, then onAppStart if required, then onSessionStart, *then* onRequestStart. If you reference the variable in any of those before onRequestStart, you'll get an error.

    Plus don't use isDefined - use structKeyExists as it's more specific.

    Known Participant
    February 21, 2012

    Thanks for the reply Owain but the error IS occuring on a file that is included from my index.cfm file, it allows application.cfc to process fully before making the include.  Sorry for the typo in my original post, omit the word "never".