With the example I have provided I would like for the index.cfm to display hello
How can I do this?
Application.cfc
<cfcomponent>
<cfset this.sessionManagement = true />
<cffunction name="onSessionStart">
<cfset SESSION.myVar = "hello">
</cffunction>
</cfcomponent>
index.cfm
<html>
<head>
<title>Testing</title>
</head>
<body>
<cfoutput>#SESSION.myVar#</cfoutput>
</body>
</html>
I have discovered that when I add
<cfinvoke component="Application" method="onSessionStart">
to the index.cfm it works, however all the variable gets overridden every time the page is refreshed.
You need to give your application a name, eg:
In your Application.cfc pseudo-constructor. Otherwise CF can't create an application, and so it cannot associate the session with the application.