Okay I figured it out.
<cfcomponent>
<cfset THIS.Name = "SessionOnlyCookiesTest" />
<cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 1, 0 ) />
<cfset THIS.SessionManagement = true />
<cfset THIS.SessionTimeout = CreateTimeSpan( 0, 0, 0, 10 ) />
<cfset THIS.SetClientCookies = false />
<cffunction name="OnError" access="public" returntype="void" output="true">
<cfargument name="Exception" type="any" required="true" />
<cfargument name="EventName" type="string" required="false" default=""
/>
<cffile
action="APPEND"
file="#expandpath('test.txt')#"
output="OnError : [#ARGUMENTS.Exception.Message# -
#ARGUMENTS.Exception.Type#] #ARGUMENTS.Exception.Detail#
#arguments.Exception.RootCause.Type#"
addnewline="true"
/>
<cfreturn />
</cffunction>
<cffunction
name="OnSessionStart"
access="public"
returntype="void"
hint="Fires when user session initializes .">
<cfcookie name="CFID" value="#SESSION.CFID#" />
<cfcookie name="CFTOKEN" value="#SESSION.CFTOKEN#" />
<cfset SESSION.DateInitialized = "#dateformat(Now())#
#timeformat(now()#" />
<cffile addnewline="yes" action="append"
file="#expandpath('test.txt')#"
output="A New Session: #SESSION.CFID# began on
#SESSION.DateInitialized#">
<cfreturn />
</cffunction>
<cffunction
name="OnSessionEnd"
access="public"
returntype="void"
hint="Fires when user session ends"
>
<cfargument name = "SessionScope" required=true/>
<cfargument name = "AppScope" required=true/>
<cflog file="#This.Name#" type="Information"
text="Session #Arguments.SessionScope.cfid# ended.">
<cfsavecontent variable="sessionvars">
<cfdump var="#Arguments.sessionscope#">
</cfsavecontent>
<cffile action="write" file="#expandpath('test.html')#"
output="A Session Ended: #sessionvars#">
</cffunction>
</cfcomponent>
Here is what I have learned that is crucial about the application.cfc:
1) The function Now() really returns now unless you use the
SESSION.DateInitialized format above. If you would like to end the session at a
specific time after it has began then you must make sure not to simply use
now().
2.) To call the session scope you must use Arguments.SessionScope. The
documentation says this but it took a while for this to sink in.
3.) Because of the errors not being traceable other than in the CFIDE logs, you
can still use a cftry/cfcatch and that generally passes your errors. (It works
well when trying to instantiate another object).
Try this:
<cftry>
<cfinvoke component="session" method="ClearSession">
<cfinvokeargument name="cfid" value="#Arguments.sessionscope.id#">
<cfinvokeargument name="cftoken" value="#Arguments.sessionscope.cftoken#">
<cfinvokeargument name="root"
value="#Arguments.applicationscope.rootdir#">
</cfinvoke>
<cffile action="append" file="#expandpath('test.html')#" addnewline="yes"
output="A Session ended ID: #Arguments.sessionscope.id#<br>">
<cfcatch>
<cffile action="append" file="#expandpath('test.html')#"
addnewline="yes"
output="A Session timed out but an error occured: CFID:
#Arguments.sessionscope.id# <br>Error: #cfcatch.Message#<br>">
</cfcatch>
</cftry>
The hardest thing to catch onto was that if I wanted to end a session using a
cfc method outside of the application.cfc, I had to pass everything as
arguments that I wanted to use.
It would be great if someone could explain this to me. Instantiating an
component object's method from application.cfc seems to not inherit the session
and application scope.
Anyways, I hope this helps others that are new to this.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321074
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4