user2335065
user2335065

Reputation: 2547

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Is there a equivalent of DynamoDB on Azure as a PHP session Handler? I found some very old articles online suggesting to use Azure Table Storage but it doesn't seem to work anymore. (https://dzone.com/articles/handling-php-sessions-windows). Thank you very much!

Upvotes: 0

Views: 98

Answers (1)

Donald Koscheka
Donald Koscheka

Reputation: 351

You can also use Azure table storage for session management. Assuming the table 'sessions' exists, this code works for me (using express-session as middleware):

const session = require('express-session');
const AzureTablesStoreFactory = require('connect-azuretables')(session);

const app = express();

const options = { table: 'sessions', sessionTimeOut: 30}; 
app.use(session({ 
  store: AzureTablesStoreFactory.create(options), 
  secret: process.env.SESSION_SECRET,
  resave: false,
  saveUninitialized: false,
  rolling: true,
  cookie: {maxAge: 600000}
}));

Upvotes: 0

Related Questions