So here’s the scenario…
a. I have a module that needs to impose a session variable (preferably using cbstorages) so that the core application can fill it or change it (called “currentprojectspace”)
b. The module should check at least ONCE (presumably onLoad()) to make sure it DOESN’T exist and if not, create it
c. Moreover, when initially setting this information, it will use a service (within the module) to connect to data to get this value
d. The core application has a debug/dev feature that allows for the clearing of the session completely with a URL variable (“clearsession=1”)
e. If FWREINIT and CLEARSESSION are both passed in the URL, the sessions should be cleared FIRST, then the reinit can continue (presumably the preReinit interception point)
f. If ONLY CLEARSESSION is passed, the session is cleared and you go to main.home
if you recognize this “pattern”, please don’t bother reading on and let me a better way to do this. I do not want the session variable I need (“currentprojectspace”) to be initialized for the first time by anything but the module so that the core does not have to be responsible but can consume what it provides, as most modules should.
Otherwise…here is what I am currently at with little success…
a. & b. & c.
in the modules ModuleConfig:onLoad() I …
function onLoad(){
LOCAL.ss = wirebox.getInstance(“SessionStorage@cbstorages”);
if (!LOCAL.ss.exists(“currentprojectspace”)) {
LOCAL.ss.set(“currentprojectspace”,123);
};
};
(the 123 hardcoded value will eventually be a getInstance(“someservice”).GetCurrentProjectSpace() )
Even though my custom modules has the dependency to cbstorages intact, on a completely “fresh” start, I get an error message in cbstorages when it tries to set() the variable that is basically telling me SESSION does not exist. In fact, if I dump session inside onLoad(), it will break telling me exactly that.
So that is the first hurdle.
d. & e. & f.
In one permutation, I can certainly get some of this part working. If I want to clear the session, I can, but the goal of the combination of using preReinit() was to allow me to clear the session and force the reinit so that the module, all modules are forced to reassert their onLoad() code so that they basically “reset” the variables that meet their session needs.