Description
Runs when a request starts.
Syntax
<cffunction name="onRequestStart" returnType="boolean"> |
See also
onRequest, onRequestEnd, Method summary, Managing requests in Application.cfc in Defining the application and its event handlers in Application.cfc in the Developing ColdFusion Applications
Parameters
ColdFusion passes the following parameters to the method:
Parameters |
Description |
---|---|
targetPage |
Path from the web root to the requested page. |
Returns
A Boolean value. Return False to prevent ColdFusion from processing the request. You do not need to explicitly return a True value if you omit the cffunction tag returntype attribute.
Usage
This method runs at the beginning of the request. It is useful for user authorization (login handling), and for request-specific variable initialization, such as gathering performance statistics.If this method throws an exception (for example, if it uses the cfthrow tag), ColdFusion handles the error and does not process the request further.If you call this method explicitly, ColdFusion does not start a request, but does execute the method code.This method can access the requested page's Variables scope only if the Application.cfc file includes an onRequest method that calls the page. You can use Request scope variables to share data with the requested page even if Application.cfc does not have an onRequest method.
Example
This example uses the authentication code generated by the ColdFusion Dreamweaver Login wizard to ensure that the user is logged in. The wizard generates code that is appropriate for Application.cfm only. To use this code with the Application.CFC, delete the generated Application.CFM
<cffunction name="onRequestStart"> |