The example in this section shows how you might implement user security by authenticating users and then allowing users to see or use only the resources that they are authorized to access.
This example has three ColdFusion pages:
This page also includes the one-button form and logic for logging out a user, which appears at the top of each page.
You can test the security behavior by adding your own pages to the same directory as the Application.cfc page.
The example gets user information from the LoginInfo table of the cfdocexamples database that is installed with ColdFusion. You can replace this database with any database containing UserID, Password, and Roles fields. The sample database contains the following data:
UserID | Password | Roles |
---|---|---|
BobZ |
Ads10 |
Employee,Sales |
JaniceF |
Qwer12 |
Contractor,Documentation |
RandalQ |
ImMe |
Employee,Human Resources,Manager |
Because spaces are meaningful in roles strings, you should not follow the comma separators in the Roles fields with spaces.
This section includes the following examples: