开发者

ColdFusion onSessionEnd problem

开发者 https://www.devze.com 2023-03-13 16:33 出处:网络
I have read man开发者_如何学Goy posts by people who have problems with onSessionEnd.This is my first conversion of application.cfm to application.cfc and the onSessionEnd is not working with the CFFun

I have read man开发者_如何学Goy posts by people who have problems with onSessionEnd. This is my first conversion of application.cfm to application.cfc and the onSessionEnd is not working with the CFFunction I am trying to invoke.

I guess what's hanging this up is how to properly call the component from the /lib/components/ folder where it resides.

When a user logs in I am creating a session array that tracks a jobNumber and the last_completed_step in that job. There are multiple jobs in a users session. At the end of the session I want to write the updated array data back to the DB.

I should make it clear that at present I look into my log file and see that the session is started - as coded in the onSessionStart shown below. Furthermore, the onSessionEnd also writes to the log file when I take out the invocation of the component. In other words if I just tell it to write "Session ended." to the log file I will see it in the log file. I have set current session timeout in CF Administrator and my app.cfc for 3 minutes for testing.

If I call the "giveMeAnswer" method in the jobState.cfc from a separate file (also at the root level) the giveMeAnswer method works properly and returns the value "I am a CFC."

If I move the jobState.cfc to the root level and set the component attribute to "jobState" I am also getting a return from the component.

<!--- Runs when your session starts --->
<cffunction name="onSessionStart" returnType="void" output="false">

<!--- :: invoke all session variables | moved out of on session start  :: --->
<cfinvoke component="#application.virtualPaths.cfcPath#system/sessionVars" method="init" />

<cflog file="#This.Name#" type="Information" text="Session started.">

</cffunction>

<!--- Runs when session times out --->

<cffunction name="onSessionEnd" returntype="void">
<cfargument name="SessionScope" type="struct" required="true" />
<cfargument name="ApplicationScope" type="struct" required="true" />

<cfinvoke component="/lib/components/jobState" method="giveMeAnswer" returnvariable="returnFromCfc">
</cfinvoke>

<cflog file="#This.Name#" type="Information" text="Session ended.  #returnFromCfc#">

<cfreturn />
</cffunction>

So, is it just not finding the component? Any other ideas?

Thanks much, Jerry


I know I've seen folks use / in component calls before, but I do not believe it is officially supported. You want to use a dot notation path instead, ala

component="lib.components.jobstate"

and assure that lib is either a subdirectory or a known CF mapping that points to the lib folder.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号