How to build Login Based CF Sites? (Session Management Problem IE9)
For years I have used one script that I found in a Ben Forte book to build membership-based ColdFusion sites. For some reason this Application.cfc script no longer works in IE9. I can still create login based sites using IE8 and Firefox with this very same script, with no problems. My question is two-fold: 1) Is this the proper way most people are still building membership-based CF sites, and 2) If this way is still acceptable, is there some workaround for IE9.
Overview of Application CFC script:
At each page request the Application.cfc file checks to see if the user is logged in. If true it brings up the requested page. On initial login, this Application.cfc file which sits in the members only folder allows only certain pages to be run, mainly the loginscript page to allow the user to initially get to the members only section. After that, the user can only reach other pages when Session.LoggedIn is true; otherwise they get kicked out to the homepage.
I have left out the DB calls and other info in the CFC file for simplicity here - like I said, this works right now in Firefox and older versions of Internet Explorer.
Application CFC file...
<cfcomponent output="no">
<cfscript>
THIS.name = "TEST";
THIS.applicationTimeout = createTimeSpan(0,2,0,0);
THIS.clientmanagement = "yes";
THIS.loginstorage = "session";
THIS.sessionmanagement = "yes";
THIS.sessiontimeout = createTimeSpan(0,2,0,0);
THIS.setClientCookies = "yes";
THIS.setDomainCookies = "no";
THIS.scriptProtect = "all";
</cfscript>
<cffunction name="onRequestStart" returntype="void" output="no">
<cfif NOT IsDefined("Session.LoggedIn")>
<cfset Session.LoggedIn=False>
</cfif>
<cfif Session.LoggedIn EQ False>
<cfif NOT (CGI.PATH_INFO EQ "/members/loginscript.cfm")>
<cflocation url="[URL to kick person out of members scetion]" addtoken="No">
</cfif>
</cfif>
</cffunction>
</cfcomponent>
<cfcomponent output="no">
<cfscript>
THIS.name = "TEST";
THIS.applicationTimeout = createTimeSpan(0,2,0,0);
THIS.clientmanagement = "yes";
THIS.loginstorage = "session";
THIS.sessionmanagement = "yes";
THIS.sessiontimeout = createTimeSpan(0,2,0,0);
THIS.setClientCookies = "yes";
THIS.setDomainCookies = "no";
THIS.scriptProtect = "all";
</cfscript>
<cffunction name="onRequestStart" returntype="void" output="no">
<cfif NOT IsDefined("Session.LoggedIn")>
<cfset Session.LoggedIn=False>
</cfif>
<cfif Session.LoggedIn EQ False>
<cfif NOT (CGI.PATH_INFO EQ "/members/loginscript.cfm")>
<cflocation url="[URL to kick person out of members scetion]" addtoken="No">
</cfif>
</cfif>
</cffunction>
</cfcomponent>
