O'Reilly logo

Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started by Charlie Arehart, Raymond Camden, Ben Forta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required