Checking and Maintaining Login Status

For instance, assume for the moment that the user has just filled out a user name/password form (more on that later), and you have verified that the user name and password are correct. You could then use a line such as the following to remember that the user is logged in:

<cfset SESSION.isLoggedIn = "Yes">

As you learned in the last chapter, the isLoggedIn variable is tracked for the rest of the user’s visit (until their session times out). From this point forward, if you wanted to ensure that the user was logged in before they were shown something, all you would need to do would be to check for the presence of the variable:

<cfif not isDefined("SESSION.isLoggedIn")> Sorry, you don't have permission to look ...

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.