
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
esr-php-session
Advanced tools
esr-php-session is a session for express, socket.io, php which doesn't suck to work together with Redis as a database.
A [esr-php-session][] is a session for express, socket.io, php, which doesn't suck to work together with Redis as a database.
Authors: Neo he is very well known in runet as Hacker Kselax Here is his [home page] to visit
[![npm version][npm-badge]][npm] [![dependency status][dep-badge]][dep-status] [esr-php-session]: https://www.npmjs.com/package/esr-php-session [npm]: https://www.npmjs.org/package/esr-php-session [npm-badge]: https://img.shields.io/npm/v/esr-php-session.svg?style=flat-square [dep-status]: https://david-dm.org/ericf/esr-php-session [dep-badge]: https://img.shields.io/david/ericf/esr-php-session.svg?style=flat-square [home page]: https://kselax.ru/en/
I built this package out of frustrations of existing packages express-session, connect-redis, express-socket.io-session. This three doesn't work properly together with redis database. and We can't find the package that allows working with php.
So this simple package was designed to work with sessions using Redis as database and three of express + socket.io + php. You can use them all together or for each separately
$ npm install esr-php-session --save
For session works properly with php+socket.io+express you have to specify the same name in any initialization. This option esr_php_session_name: 'my_session', should be equal otherwise they can't work simultaneously and to know each other
Include to file
var esr_php_session = require('esr-php-session');
in middlewire add this lines
For using with express
app.use(esr_php_session.express_session({
esr_php_session_name: 'my_session',
secret: 'my new secret',
maxAge: (60 * 60 * 24), // by default 24 hours
ex: 60,
}));
then you can put variables to res.esr_php_session
something like res.esr_php_session = some_value and this value will saved and will available on next reload page.
For using with socket.io
io.use(esr_php_session.socket_io_session({
esr_php_session_name: 'my_session',
secret: 'my new secret',
maxAge: (60 * 60 * 24), // by default 24 hours
ex: 60,
}));
now for you available socket.esr_php_session and you can put there some variable like socket.esr_php_session.views = 30
at first find file /node_modules/esr-php-session/Esr_php_session.php and include it to your php project
require_once 'Esr_php_session.php';
then create an object
$obj = new Esr_php_session(array(
'esr_php_session_name' => 'my_session',
'secret' => 'my new secret',
'maxAge' => (60 * 60 * 24), // by default 24 hours
'ex' => 60,
));
that's it, when you create an object in this time will be automatically added to $_COOKIE a new element with name of your session $_COOKIE[esr_php_session_name]
const express = require('express');
const esr_php_session = require('esr_php_session');
var app = express();
app.listen(3000);
app.use(esr_php_session.express_session({
esr_php_session_name: 'my_session',
secret: 'my new secret',
maxAge: (60 * 60 * 24), // by default 24 hours
ex: 60,
}));
app.get('/', function(req, res){
console.log(req.esr_php_session.views);
if(req.esr_php_session.views || req.esr_php_session.views == 0){
req.esr_php_session.views++;
}else{
req.esr_php_session.views = 0;
}
console.log('req.esr_php_session.views = ', req.esr_php_session.views);
res.send('Views = ' + req.esr_php_session.views);
});
...
io.use(esr_php_session.socket_io_session({
esr_php_session_name: 'my_session',
secret: 'my new secret',
maxAge: (60 * 60 * 24), // by default 24 hours
ex: 60,
}));
io.on('connection', function(socket){
console.log('connected socket.id = ' + socket.id);
if(socket.esr_php_session){
if(socket.esr_php_session.views){
socket.emit('message', socket.esr_php_session.views);
}else{
socket.esr_php_session.views = 0;
socket.emit('message', socket.esr_php_session.views);
}
}
console.log(socket.esr_php_session.views);
}
See on github in folder examples or inside package in /node_modules/esr-php-session/examples
This software is free to use under GNU General Public License GPL. See the license description for license text and copyright information.
FAQs
esr-php-session is a session for express, socket.io, php which doesn't suck to work together with Redis as a database.
We found that esr-php-session demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.