Cannot get onSession Start to fire in Mura

299 views Asked by At

I have a script :

<cfscript>
     gf = createObject('component','com.general');
     gf.checkIpBlocked();
</cfscript>

that I want to fire onSessionStart.

I added an onSessionStart to /siteID/includes/themes/myTheme/eventHandler.cfc. But the session start NEVER fires. I know there is something managing sessions because of I open the admin, login then close the browser, re-open it I am forced to login again.

If I set a session variable close the browser and and the session.testVar never goes away and seems to hold the initial value for a very long time.

I am not trying to manage mura users or anything I am just trying to set a session variable the first time in a "session". In a typical application.cfc this is easy.

Any insight is appreciated.

2

There are 2 answers

6
Miguel-F On

The Mura docs state that the application events are actually onGlobalSessionStart and/or onSiteSessionStart.

Application Events

onApplicationLoad       onSiteSessionStart
onGlobalSessionStart    onSiteSessionEnd
onSiteMissingTemplate   onSiteError
onGlobalError           onBeforeAutoUpdate
onAfterAutoUpdate       onGlobalThreatDetect

Note that Events that begin with onGlobal are deļ¬ned on a per-Mura instance basis.

Mura docs.

1
Matt Levine On

Unfortunately, that's a bug. However, one thing to keep in mind is that onSiteSessionStart is unreliable since it only fires when a siteID is defined within the request. For example, if you were to go to the admin and be asked to login your session will have started and there would have been no siteID.

For now I would try using onSiteRequestStart to param the variable instead.

function onSiteRequestStart($){
    param name="session.ipChecked" default=false;
    if(!session.ipChecked){
        var gf = createObject('component','com.general');
        gf.checkIpBlocked();
        session.ipChecked=true;
    }
}

In regard to our documentation we have three Mura 6 books available both printed and digital downloads from Lulu

And are also working to create a systematic way to post the contents of those books on our support site which we are hoping to complete by MuraCon on 9/30. So that the all of our documentation will stay update and in sync.