V
V
VaaL20042014-10-01 15:00:39
PHP
VaaL2004, 2014-10-01 15:00:39

How to make single sessions for Node.js and PHP on Redis?

Hello, such a situation:
There is a server on Node.js and a site on PHP. It is required to use shared sessions ($_SESSION). In node.js, I achieved the use of sessions in redis using connect-redis.

app.use(session({
    store: new RedisStore({
        // this is the default prefix used by redis-session-php
        prefix: 'session:php:'
    }),
    // use the default PHP session cookie name
    name: 'PHPSESSID',
    secret: '    ',
    resave: true,
    saveUninitialized: true
}));

In PHP I use redis-session-php :
require('/common/redis-session-php/redis-session.php');
RedisSession::start();

Everything is fine here and there, and the session data is recorded in Redis. However, they are written to the keys under their own names:
session:php:ALvgE6rcXdpXvHQEBWC6qgrSLJ1dGsqT - from Node.js
session:php:a46s4ivft89vkpa6phnmj2i931 - from PHP
Therefore, Node.js sees its sessions, and PHP sees its own.
How to make them write in one session?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Grechushnikov, 2014-10-02
@VaaL2004

great game with cookies (only) for linking sessions between each other
I no longer see solutions

D
DigSil, 2014-10-03
@DigSil

I found a good article, not much off topic, but close to solving the problem of Node.js + PHP - integration

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question