We're trying to implement some very simple security for one of our applications.
We have the security working via an included header.cfm file. But we'd like to incorporate it into the application.cfm file so that we don't have to remember to include the header for each new file we create.
Here is what we would like to do:
Application.CFM
<cfapplication name="phonelog_app" sessionmanagement="Yes" setclientcookies="No">
<!--- Set the application datasource, and logic to only set it once so runtime is minimized --->
<cfset Cookie.CFID = session.CFID>
<cfset Cookie.CFTOKEN = session.CFTOKEN>
<cfif not IsDefined("application.Initialized"
>
<cfset application.DS="phonelog">
<cfset application.Initialized="Yes">
</cfif>
<cfif isdefined("session.loggedin"
>
<cfif session.loggedin eq "no">
<cfinclude template="login.cfm">
<cfelse> <!--- session.loggedin defined and is not "no" --->
<!--- output common file header information --->
</cfif>
<cfelse>
<cfinclude template="login.cfm">
</cfif>
The login.cfm file displays the actual username/password entry and calls a sub-page called password.cfm that performs the query and authenticates.
Now this does SEEM to work up to a point, it displays the login page, BUT - it continues on to display whatever other page you may have entered. IE index.cfm loads both the login.cfm and the contents of the index.cfm file.
If anyone can suggest a better scheme that doesn't require us having to have the login check in an included header.cfm file - it would be greatly appreciated.
Thanks!
We have the security working via an included header.cfm file. But we'd like to incorporate it into the application.cfm file so that we don't have to remember to include the header for each new file we create.
Here is what we would like to do:
Application.CFM
<cfapplication name="phonelog_app" sessionmanagement="Yes" setclientcookies="No">
<!--- Set the application datasource, and logic to only set it once so runtime is minimized --->
<cfset Cookie.CFID = session.CFID>
<cfset Cookie.CFTOKEN = session.CFTOKEN>
<cfif not IsDefined("application.Initialized"

<cfset application.DS="phonelog">
<cfset application.Initialized="Yes">
</cfif>
<cfif isdefined("session.loggedin"

<cfif session.loggedin eq "no">
<cfinclude template="login.cfm">
<cfelse> <!--- session.loggedin defined and is not "no" --->
<!--- output common file header information --->
</cfif>
<cfelse>
<cfinclude template="login.cfm">
</cfif>
The login.cfm file displays the actual username/password entry and calls a sub-page called password.cfm that performs the query and authenticates.
Now this does SEEM to work up to a point, it displays the login page, BUT - it continues on to display whatever other page you may have entered. IE index.cfm loads both the login.cfm and the contents of the index.cfm file.
If anyone can suggest a better scheme that doesn't require us having to have the login check in an included header.cfm file - it would be greatly appreciated.
Thanks!