通过我提供的示例,我希望 index.cfm 显示hello
我该怎么做?
应用程序.cfc
<cfcomponent>
<cfset this.sessionManagement = true />
<cffunction name="onSessionStart">
<cfset SESSION.myVar = "hello">
</cffunction>
</cfcomponent>
索引.cfm
<html>
<head>
<title>Testing</title>
</head>
<body>
<cfoutput>#SESSION.myVar#</cfoutput>
</body>
</html>
我发现当我添加
<cfinvoke component="Application" method="onSessionStart">
到 index.cfm 它可以工作,但是每次刷新页面时都会覆盖所有变量。