我創建了下面的Application.cfc,除了一件事情之外,一切正常。我試圖讓Application.cfc在短時間不活動後退出。但是,我的ApplicationTimeout
或SessionTimeout
都沒有奏效。Coldfusion 10 sessionTimeout不能正常工作
有沒有人有任何建議?
謝謝
<cfcomponent>
<cfset This.name = "AndWhat">
<cfset This.sessionManagement="True">
<cfset This.loginstorage="session">
<cfset This.datasource = "database">
<cfset This.ormenabled = "true">
<cfset This.applicationTimeout = createTimeSpan(0, 0, 1, 0)>
<cfset This.sessionTimeout = createTimeSpan(0, 0, 1, 0)>
<cffunction name="onRequestStart" access="remote" >
<cfif IsDefined("Form.logout")>
<cflogout>
</cfif>
<cflogin >
<cfif NOT IsDefined("cflogin")>
<cfinclude template="loguser.cfm">
<cfabort>
<cfelse>
<cfif cflogin.name IS "" OR cflogin.password IS "">
<cfoutput>
<script type="text/javascript">
alert("Um, Really?! Please supply a valid username and password!");
</script>
</cfoutput>
<cfinclude template="loguser.cfm">
<cfabort>
<cfelse >
<cfquery name="myNewLoginQuery" dataSource="database">
SELECT username, password, policy
FROM people
WHERE
username = '#cflogin.name#'
AND password = '#cflogin.password#'
</cfquery>
<cfif loginQuery.policy NEQ "">
<cfloginuser name="#cflogin.name#" Password = "#cflogin.password#">
<cfelse>
<cfoutput>
<script type="text/javascript">
alert("Um, Really?! Please supply a valid username and password!");
</script>
</cfoutput>
<cfinclude template="loguser.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
</cflogin>
</cffunction>
</cfcomponent>
不知道,但不應該在'onSessionStart()',而不是'onRequestStart()'上管理會話中心的東西?如果你可以避免,我也可能不打擾''。這真的沒有帶來太多的表。 –
只是隨機猜測:嘗試爲應用程序超時和會話超時設置不同的時間跨度。應用程序通常是幾個小時,會話是30分鐘左右。目前它們在你的代碼中是一樣的,它可能是問題的根源。 – Sergii
此外,你怎麼知道超時不起作用?我建議實現'onSessionEnd()'處理程序並使用'cflog'來記錄超時。您將獲得更多有關該研究的信息。 – Sergii