如何在nodejs和codeigniter之间共享会话(redis)

osh3o9ms  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(297)

我想读取可以登录到codeigniter的node.js会话,但无法读取nodejs端的会话。
我无法读取在php端的nodejs端作为试用创建的会话。
redis db:在此处输入图像描述在此处输入图像描述;

$config['sess_driver'] = 'redis';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'tcp://localhost:6379?auth=XXXXXXXXXXXX&database=0&timeout=604800';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

节点js;

const createError = require('http-errors');
const express = require('express');
const session = require('express-session');
const redis = require('redis');

const redisClient = redis.createClient({
    host: 'localhost',
    auth_pass: "XXXXXXXXXXX"
});

const redisStore = require('connect-redis')(session);
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');

const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');

const app = express();

redisClient.on('error', (err) => {
    console.log('Redis error: ', err);
});

app.use(session({
    secret: 'sercan',
    name: 'ci_session',
    resave: false,
    saveUninitialized: true,
    cookie: {
        secure: false,
        maxAge: 1000 * 60 * 60 * 24 * 7
    },
    store: new redisStore({prefix: 'ci_session:', host: 'localhost', port: 6379, client: redisClient, ttl: 86400 })
}));

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题