【问题标题】:ColdFusion onSessionEnd problemColdFusion onSessionEnd 问题
【发布时间】:2011-06-15 15:28:11
【问题描述】:

我已经阅读了许多对 onSessionEnd 有问题的人的帖子。这是我第一次将 application.cfm 转换为 application.cfc,并且 onSessionEnd 无法与我尝试调用的 CFFunction 一起使用。

我猜这个问题的关键在于如何从它所在的 /lib/components/ 文件夹中正确调用组件。

当用户登录时,我正在创建一个会话数组,用于跟踪该作业中的 jobNumber 和 last_completed_step。用户会话中有多个作业。在会话结束时,我想将更新后的数组数据写回数据库。

我应该明确表示,目前我查看我的日志文件并看到会话已启动 - 如下所示 onSessionStart 中的代码。此外,当我取出组件的调用时,onSessionEnd 也会写入日志文件。换句话说,如果我只是告诉它写“会话结束”。到日志文件,我将在日志文件中看到它。我在 CF Administrator 和我的 app.cfc 中设置了当前会话超时 3 分钟以进行测试。

如果我从单独的文件(也在根级别)调用 jobState.cfc 中的“giveMeAnswer”方法,giveMeAnswer 方法可以正常工作并返回值“我是 CFC”。

如果我将 jobState.cfc 移动到根级别并将组件属性设置为“jobState”,我也会从组件中获得回报。

<!--- 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>

那么,是不是找不到组件?还有其他想法吗?

非常感谢,杰瑞

【问题讨论】:

    标签: coldfusion application.cfc


    【解决方案1】:

    我知道我以前见过人们在组件调用中使用 /,但我不相信它得到官方支持。您想改用点符号路径,ala

    component="lib.components.jobstate"

    并确保 lib 是指向 lib 文件夹的子目录或已知 CF 映射。

    【讨论】:

      猜你喜欢
      • 2011-04-02
      • 2014-11-06
      • 1970-01-01
      • 1970-01-01
      • 2012-08-11
      • 2011-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多