Practical application
In this section, we are going to discuss a couple of variations on where and how to use scoped persistence. This means by using one of the scopes listed earlier, we can have a variable or CFC object last for the entire visibility period in the table.
Let us say we create a CFC called user.cfc
, and then inside the Application.cfc
in the onSessionStart()
method, we created an instance of the class. We would want our object to last for the full life of our session. We would create code similar to this to enhance our former code for the sessionStart
method. If we check out the example code on the site, the user.cfc
file has already been created. Here is the modified version. The modified code is an example of how we would create a persistent object for the user. It would last until the session expires. One of the best things about application, session, and request scoped variables and objects is that they exist until that scope expires and the server takes care of clearing...