Working with onSessionStart and onSessionEnd

Earlier in the chapter, we talked about how session variables can be enabled in the Application.cfc file and how handy they are for tracking information about your users. Another feature you may find handy is the ability to run code at both the beginning and end of a session. There are many ways this can be useful. Let’s say that you want to note when a user first enters your system. You can do this easily with this code:

<cfset SESSION.entered = now()>

This line of code is simple enough. However, you want to run it only once. You could use the isDefined function to check whether the variable exists, but an even easier approach is to use the onSessionStart method of the Application.cfc file. This is ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.