[wirebox-2.0.0] Dropping Session scope from wirebox

binder.map(“CurrentUser”).to("#moduleMapping#.models.User").into(binder.SCOPES.SESSION).asEagerInit();

I will often have a security or user module that will provide for a special mapped instance of my user class to “currentuser” in the binder session scope for authentication. In dev, I often run into situations where I have to modify this class and need to reinit it. How can I clear the current contents of the binder scope session and then on the next event call, it will be reset because the wirebox will see it is not longer bound? Found some pretty cool things in the wirebox like GetScopeStorage().Delete (which does not seem to remove anything), so I figured I’d better ask before I rewrite an entire site chasing a simpler solution. What I have done in the past is (1) drop session management to 30 seconds or (2) remove it from session scope and reload it on every call in the dev environment.

Thoughts?

Mike

There is no way to clear references out of every session. None of the CF engines give any documented API for interacting with any session other than your own. This can be a clean reinit hard. What I’ve done in the past, is making an interceptor that clears the session scope on reinit, but that still only works for me when I’m testing. If you want to get a little fancy, you could write an interceptor that on each request would check a date mapped in wirebox as a constant and compare it to a value in session for the given user and wipe out any session storage for them if WireBox has been reloaded since the session storage was created.

Hmm, kind of makes me wonder if WireBox could try to handle this by storing some metadata in the session scope and checking it to see if it was stale every time.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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