Using DB for sessions

I’m trying to configure our app to use a database for server sessions. I have mariahdb setup, and created a datasource called ‘dbSessions’ per instructions here:

Here is the datasource config per Lucee Admin

/lucee/admin/web.cfm?action=services.datasource&action2=create&name=dbsessions

this.datasources["dbsessions"] = {
	  class: 'org.gjt.mm.mysql.Driver'
	, connectionString: 'jdbc:mysql://192.168.200.211:3306/dbSessions?useUnicode=true&characterEncoding=UTF-8&autoReconnect=false&jdbcCompliantTruncation=true&useLegacyDatetimeCode=true'
	, username: 'dbuser'
	, password: "encrypted:bfa737b5a4dcf20743bf5acbb7ea551c3b91aab3fdda2cbee67eaefb357ef7fc8f7e21a1160837f8"
	
	// optional settings
	, clob:true // default: false
	, connectionLimit:100 // default:-1
	, timezone:'UTC'
	, storage:true // default: false
};

And at server scope, I’ve enabled ‘dsn: dbSessions’ for Session Storage. I should add that the datasource verifies within Lucee Admin.

The error I’m getting when the app runs

datasource [dbsessions] is not enabled to be used as session/client storage, you have to enable it in the Lucee administrator or define key "storage=true" for datasources defined in the application event handler.

I’m honestly not quite sure what I’m doing wrong here. End goal is to get sessions stored in the db so we can better fail over between servers.

The first time Lucee tries to store data in this table, it’ll need to create the relevant columns. Give the dbuser account full privileges until this table is populated with some data, then you can return it to select/insert/update/delete.

1 Like

There’s a flag on data source in the admin to allow using for sessions which you set, hmmmm, which version of lucee?

1 Like

Per the datasource config, the dbuser should have full permissions. I also checked mariadb user table and it also has permissions.

I have the datasource enabled for session storage.

Has the cf_session_data table been created? If not, create it yourself and see if that sorts it:

CREATE TABLE cf_session_data (
expires varchar(64) NOT NULL,
cfid varchar(64) NOT NULL,
name varchar(255) NOT NULL,
data longtext NOT NULL
);

1 Like

Hi,

I created the table as suggested. I did it as a cfquery script so that it would use the same permissions. It created the table without issue.

I’m still getting the following error:

datasource [dbsessions] is not enabled to be used as session/client storage, you have to enable it in the Lucee administrator or define key "storage=true" for datasources defined in the application event handler.

yup the error is a Lucee error message, nothing to do with db permissions

1 Like

I went ahead and deleted the datasource from Lucee.

I used the script it generated when I first made it and put it in the application.cfc file.

Things seem to be working now.

Not quite sure what the snafu was.

EDIT:

I deleted entry from application.cfc, and redid it through Lucee Admin. Didn’t encounter the problem again. My install is a few versions behind, fyi.