Create a Protected Area / Including the User Check
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.
Learn More
Subtitles of the Movie
The last step is to create an include file that we can use to test for the presence of the session variable user id. If the variable exists, we know the user has logged in. If it doesn't exist, we know the user needs to log in. We'll create a file called _affirm.cfm and save it in the root directory. This is so it can easily be referenced by any file. We will remove the HTML and add page comments. Here is the entire contents of the file. cfif NOT isdefined, session.userid, cflocation which is a redirect Cold Fusion tag, addtoken is "no" and URL is "wherestom/index.cfm" and that's all that is in this file. If the session variable user id does not exist, the user is redirected to the application main page out of the admin area completely. To protect our pages then we would simply include this file at the top of each page. This is written as an include file so that if we need to we can change the way we check for validation and we would only need to change it in one file. Now we can add the include statement to each main function file in the application. Using a single main file with the set of include files like activities.cfm or users.cfm, let's you reference the security include file only once for several functions like validate, data result, search and display. When we try to go to a page in the admin area, for example activities, with the step of search, and we haven't logged in, we are returned to the application main page. However, if we temporarily commented out the include for that security check, And then tried again, to go to admin, activities.cfm step equals search, you'll see that we get right in there. Now we'll put that include file back in, hit refresh and we're redirect it back to the index page of the application. Altogether this is a safe and efficient way to protect our "Where's Tom" admin area. r this is a safe and efficient way to protect our "Where's Tom" admin area.
Tutorial Information
| Course: | Macromedia ColdFusion MX |
| Author: | Darcey Spears |
| SKU: | 33474 |
| ISBN: | 1932072772 |
| Release Date: | 2004-03-05 |
| Duration: | 6.5 hrs / 102 lessons |
| Work Files: |
Yes |
| Captions: | For Online University members only |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 