Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Created August 7, 2014 23:13
Show Gist options
  • Save stevewithington/c171d9d93d58440af9d1 to your computer and use it in GitHub Desktop.
Save stevewithington/c171d9d93d58440af9d1 to your computer and use it in GitHub Desktop.
Mura CMS : Session Variable Example
<cfscript>
public any function onSiteRequestStart($) {
param name='session.customsession' default=getDefaultCustomSessionSettings();
// you could use whatever trigger you want to set your session var(s), but i'm just using something simple for this example
if ( IsDefined('url.somekey') ) {
lock scope='session' type='exclusive' timeout=10 {
session.customsession = {
somekey = url.somekey
, dateinitalized = Now()
, inited = true
}
}
}
}
public void function onGlobalSessionStart($) {
WriteLog(text='custom session started', type='information', application=true, file='customsession');
}
public void function onGlobalSessionEnd($) {
WriteLog(text='custom session expired', type='information', application=true, file='customsession');
}
public void function onSiteSessionEnd($) {
onGlobalSessionEnd(argumentCollection=arguments);
}
private any function getDefaultCustomSessionSettings() {
return {
somekey = ''
, dateinitalized = ''
, inited = false
};
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment