RE: [coldbox:17876] [Coldbox 3.6] Recommended way to persist a single variable?

The easiest way is to persist it using flash RAM. This entry explains how to do it when redirecting:

Here’s the docs on it:

Also, you could get fancy and use the Flash RAM directly:

The biggest reason I don’t use the Flash RAM persistence with setNextEvent, is it clears out after it’s used and if the user hits the refresh button, the variable won’t be there any longer.

Also, feel free to use session storage as well. There’s a nice ColdBox plugin called SessionStorage that gives you a nice API to store and retrieve values:

And for the record, at the end of the day there’s absolutely nothing keeping you from just directly accessing the good old session scope directly. The main issue there is you can’t mock it if you’re writing unit tests because it breaks encapsulation.



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

The Sessionstorage and applicationstorage plugins look like what i’m looking for. I understand that I can always go back to just directly accessing session and application but I’m trying to fully give in to the dark side first before taking the easy way out.

Do you know of any examples in the sample apps or other that show sessionstorage being used? The examples are blank on the wiki page.