Still within our myApp
folder, edit the Application.cfc
file and let's turn on session management—this tells our application that we want to enable sessions per user. We do this by adding <cfset this.sessionmanagement = true>
in our code:
<cfcomponent> <cfset this.name = "MyApplication"> <cfset this.sessionmanagement = true> </cfcomponent>
1. If you now change the code in
index.cfm
to<cfdump var="#SESSION#">
and call the page, you will see the following:2. Let's set a variable, so let's change our
index.cfm
to the following:<cfset SESSION.myID = "12345"> <cfdump var="#SESSION#">
3. By running the code we now see that our variable
myID
is in the session:4. Now that that variable has been set, let's remove the code
<cfset SESSION.myId = "12345">
fromindex.cfm
so thatmyID
will not be set in the session scope again. When you reload the page, you'll still find our variable...