'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!
Solution 1:[1]
Is there a equivalent of DynamoDB on Azure as a PHP session Handler?
As suggested by Oury Ba, adding gist as a community wiki to help community members who might have a similar question:
- For session handling, you can use Azure Cache for Redis as a PHP session cache, specify the connection string to your Azure Cache for Redis instance in
session.save_path
For example:
session.save_path = "tcp://mycache.redis.cache.windows.net:6379?auth=<url encoded primary or secondary key here>";
You can refer to Azure Cache for Redis development FAQs and PHP Session handler
Solution 2:[2]
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}
}));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Donald Koscheka |