Skip to content

Instantly share code, notes, and snippets.

@roryl
Last active April 28, 2017 08:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roryl/44f730ecd8ba2593b03e45f1189fcf5f to your computer and use it in GitHub Desktop.
Save roryl/44f730ecd8ba2593b03e45f1189fcf5f to your computer and use it in GitHub Desktop.
Lucee Database Session Storage
USE lucee_sessions;
ALTER TABLE cf_session_data ADD PRIMARY KEY(cfid,name);
component {
this.datasources["lucee_sessions"] = {
class: 'org.gjt.mm.mysql.Driver'
, connectionString: 'jdbc:mysql://192.168.33.10:3306/lucee_sessions?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true'
, username: 'lucee_sessions'
, password: "encrypted:8c3ea865feab8133a7614f58aee150cddee0ed6f82a476f1"
// optional settings
, storage:true // default: false
};
this.sessionTimeout = createTimeSpan(0,0,20,0); //Set a default session timeout of 20 minutes
this.sessionStorage = "lucee_sessions"; //Set our session storage to the lucee_sessions datasource
this.sessionCluster = true; //Set true if more than one Lucee instance connected to the same sessison store
this.sessionType = "cfml"; //Needed for session clustering
function onSessionStart(){
session.someData = "My Data";
}
}
CREATE DATABASE lucee_sessions;
CREATE USER lucee_sessions@'localhost' identified by '123456';
GRANT ALL ON lucee_sessions.* to lucee_sessions@'localhost' identified by '123456';
FLUSH PRIVILEGES;
<cfdump var="#now()#">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment