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:
http://www.quackfuzed.com/index.cfm/2008/6/10/ColdBox-Using-Persist

Here’s the docs on it:
http://wiki.coldbox.org/wiki/EventHandlers.cfm#setNextEvent

Also, you could get fancy and use the Flash RAM directly:
http://wiki.coldbox.org/wiki/FlashRAM.cfm

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:
http://wiki.coldbox.org/wiki/Plugins:SessionStorage.cfm

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.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

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.