ColdFusion onSessionEnd 问题

发布于 2024-11-15 17:15:47 字数 1610 浏览 2 评论 0原文

我读过很多对 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>

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

非常感谢,杰瑞

I have read many 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小镇女孩 2024-11-22 17:15:47

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

component="lib.components.jobstate"

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文