Adobe COLDFUSION 9 Manual page 251

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
Session resources include variables that store data that is needed throughout the session, such as account numbers,
shopping cart contents, or CFCs that contain methods and data that are used by multiple pages in a session.
Note: Do not include the
cflogin
at the start of the session; it cannot handle user logout, and cannot fully ensure security.
Using the onSessionStart method
This method is useful for initializing session data, such as user settings or shopping cart contents, or for tracking the
number of active sessions. You do not need to lock the Session scope when you set session variables in this method.
For more information, see the onSessionStart entry in the CFML Reference.
Using the onSessionEnd method
Use this method for any clean-up activities when the session ends. (For information on ending sessions, see
a
session" on page 315.) For example, you can save session-related data, such as shopping cart contents or information
about whether the user has not completed an order, in a database, or you can log the end of the session to a file. You
cannot use this method to display data on a user page, because it is not associated with a request.
Note: Sessions do not end, and the
see the onSessionEnd entry in the CFML Reference.
Managing requests in Application.cfc
ColdFusion provides three methods for managing requests:
ColdFusion processes requests, including these methods, as follows:
ColdFusion always processes
1
If you implement an
2
onRequest
implement an
onRequest
3
ColdFusion always processes
You can use each of the Application.cfc request methods to manage requests as follows:
Using the onRequestStart method
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 you use the
onRequestStart
the request when it finishes processing the
Note: If you do not include an
a Variables scope with the requested page, but it does share Request scope variables.
For more information, see the entry for onRequestStart in the CFML Reference
User authentication
When an application requires a user to log in, include the authentication code, including the
calls this tag, in the
onRequestStart
request. For detailed information on security and creating logins, see
example that uses authentication code generated by the Adobe Dreamweaver CF Login Wizard, see onRequestStart in
the CFML Reference.
tag or basic login processing in the onSessionStart method, as the code executes only
method is not called when an application ends. For more information,
onSessionEnd
at the start of the request.
onRequestStart
method, ColdFusion processes it; otherwise, it processes the requested page. If you
method, explicitly call the requested page in your
at the end of the request.
onRequestEnd
method and do not use the
onRequestStart
method in Application.cfm file, the
onRequest
method. Doing so ensures that the user is authenticated at the start of each
Last updated 8/5/2010
,
onRequestStart
onRequest
onRequest
method, ColdFusion automatically processes
onRequest
code.
onRequestStart
"Securing
Applications" on page 339 For an
"Ending
, and
.
onRequestEnd
method.
method does not share
tag or code that
cflogin
246

Advertisement

Table of Contents
loading

Table of Contents