For some reason I can't get session management to work - i declared the session variable, i even put the cfapplication tag on every page, and my settings in the admin area are correct(i believe). Here's my code:
(login.cfm)
<CFAPPLICATION NAME="Security_Test" CLIENTMANAGEMENT="YES" SESSIONMANAGEMENT="YES" SESSIONTIMEOUT=#CreateTimespan(0,0,30,0)#>
<cfif isDefined("Form.UserName"
is true and isDefined("Form.Password"
is true>
<cfquery datasource="chcf" name="oConnLogin">
sp_login @UserName='#Replace(Form.UserName,"'","''","ALL"
#',@Password='#Replace(Form.Password,"'","''","ALL"
#'
</cfquery>
<cfif oConnLogin.recordcount is 0>
<cfinclude template="../inc/header.inc">
The login and password you entered was incorrect. Please re-enter the User Name and Password.
<cfelse>
<cflock timeout=2>
<cfSet Session.UserName = Form.UserName>
<cfSet Session.UserID = oConnLogin.ContactID>
</cflock>
<cflocation URL="/" addtoken="yes">
</cfif>
</cfif>
(index.cfm)
<cfif isDefined("Session.UserID"
is false>
<br>You are not currently logged in.<br><br>
<cfelse>
You are currently logged in as: <cfoutput>#Session.UserName#</cfoutput>
</cfif>
(login.cfm)
<CFAPPLICATION NAME="Security_Test" CLIENTMANAGEMENT="YES" SESSIONMANAGEMENT="YES" SESSIONTIMEOUT=#CreateTimespan(0,0,30,0)#>
<cfif isDefined("Form.UserName"
<cfquery datasource="chcf" name="oConnLogin">
sp_login @UserName='#Replace(Form.UserName,"'","''","ALL"
</cfquery>
<cfif oConnLogin.recordcount is 0>
<cfinclude template="../inc/header.inc">
The login and password you entered was incorrect. Please re-enter the User Name and Password.
<cfelse>
<cflock timeout=2>
<cfSet Session.UserName = Form.UserName>
<cfSet Session.UserID = oConnLogin.ContactID>
</cflock>
<cflocation URL="/" addtoken="yes">
</cfif>
</cfif>
(index.cfm)
<cfif isDefined("Session.UserID"
<br>You are not currently logged in.<br><br>
<cfelse>
You are currently logged in as: <cfoutput>#Session.UserName#</cfoutput>
</cfif>