[ColdBox 4.1] Custom Interceptor for system settings

I am trying to setup a custom interceptor which will grab some data from a database and set those as session variables which can be used throughout the user’s session. First off, is an interceptor the way to go with this? Second, I am getting the error below. I have never written my own interceptor so this is all new to me. Any help is greatly appreciated. Thanks!

Error:

Event: security.Home
Routed URL: N/A
Layout: lay_default.cfm (Module: )
View: v_warning
Timestamp: 05/19/2015 01:39:55 PM

Without the stack trace, I can’t really tell what’s going on, but I’m guessing you’re using the cbdebugger module and it’s trying to announce an interception point before it’s been registered with the interceptor service.

I don’t think any of the code you showed in your interceptor is an issue. However, I do think you’re a bit confused about what interceptor point to use. afterConfigurationLoad will only fire ONCE-- after the app inits. Therefore, if you want to set session data for every single user’s session, you will want to use a different interception point-- namely sessionStart.

http://wiki.coldbox.org/wiki/Interceptors.cfm#Application_Life_Cycle

You may also want to consider simply having a session-scoped CFC that stored data related to the user. Just put the scope annotation at the top of your component like so:

component scope=“session” {}

Ask WireBox to give you the CFC any time you need it. All the creation and persistence will handled automatically for you. A separate CFC will be created for each user’s session and get stored in the session scope but you won’t have to do nearly as much work.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

OK, I got the error to go away and the session setting working. Still would like some feedback if this is the best route to go. Thanks!

Ok thanks. These are the system settings which don’t really apply to the user but settings which are used for session timeouts, inactivity durations etc and are used as a user is in the system (guess I kind of worded it poorly). The reason for storing in database is so that sys admins can change these settings.

The data associated w the actual user is done w a user bean w setters and getters.

Thanks
Chad

Is there any way to clear out the components in the session scope besides restarting the ColdFusion service? Fwreinit does seem to do the job.

Thanks!
Chad

In all sessions, or just the current one?

If you want to clear all sessions, no there is no way to do it unless you set some application-level flag and have each request check, it and do a clear on the session scope then.
If you want to just clear the current session structClear( session ) will work, but perhaps you can explain what you’re trying to do.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

I was just adding some properties to my bean, and I can only get it to re-init and get the new properties by restart the CF service.

Thanks,
Chad

If you’re just testing for yourself, I’ve created an interceptor in the past that looks for ?clearsession=1 in the URL and just does a structClear( session ) You can also do it on fwreinit. There’s even an interception point for that.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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