Thank you but what I want to know is if there another recommended way to store a value in the coldbox framework instead of in the session scope.
The code snippet I gave was just an example of how I would persist a variable when not using the coldbox framework.
Thanks for pointing out Main.cfc, I had not seen it in the documents. I assume that this is the replacement for code that would normally go into application.cfc.
Talking about prc, I like to stuff a couple things from the session into the event object because it’s very convenient and I don’t have to keep injecting the sessionstorage plugin, since per request, the event object is automatically passed around by Coldbox. So one thing I do is, in my onRequestStart method of my global handler (defined in config), let’s say I have a session variable in sessionstorage that has my current user object for the site but what I need commonly is just the users id:
function onRequestStart(event, rc, prc) {
if (getPlugin(“SessionStorage”).exists(“siteuser”)) {
prc.currentUserId = getPlugin(“SessionStorage”).getVar(“siteuser”).getUserId();
} else {
prc.currentUserId = 0;
};
};
Now, in just about ANY coldbox “thing”, prc.currentUserId is all I need and I can ALWAYS count on it being available during the request. Just another option.