Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnRequestStart on coldfusion

Tags:

coldfusion

Is their away to force OnSessionstart to run again on OnrequestStart if needed.

I'm building a site where alot of variables are created based on a dynamic subdomain. So I'll want to check onRequestStart if the the domain is the same if not reset the session variables.

Does this make sense and is there a better solution?

like image 710
Prak Avatar asked Nov 22 '25 11:11

Prak


2 Answers

onSessionStart should be triggered by a different subdomain - those would be different cookies.

However, if code in the ColdFusion Application events needs to be shared or re-run, break them out into their own functions and run them from multiple events. This is how most frameworks run their "reinit" functions: application is init'ed when it starts, but also via URL. The shared function is called, not the original application event.

like image 137
Billy Cravens Avatar answered Nov 25 '25 11:11

Billy Cravens


Answer your first question, yes. You CaN call onSessionstart directly, like so:

<cfset onSessionstart()>

However, all that does is start the session and allows you to execute certain code whenever a new session starts. CF already automatically starts a new session when one is warranted.

Reading on it seems what you want to do is set domain specific session variables. That can be done any number of ways but probably the least "good" way to do it would be by calling the onSessionstart method again. The reason I say this is that whatever you are doing in the onRequestStart method, you could/should be doing in onSessionstart. That is, whatever info you have available to you in onRequestStart insofar as which domain the user is using is available in onSessionstart.

That and, you can set a session variable anywhere in the code of your site. It doesn't HAVE to be done in onSessionstart.

like image 36
coldfusiondevshop Avatar answered Nov 25 '25 09:11

coldfusiondevshop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!