Error - expressSessionMiddleware is not a function


New Member
I'm trying to use to sockets with the users' sessions, but I keep getting this error when I try add the middleware. Here is my code:
var express = require('express');
var socket = require('');
var sharedSession = require("");

function main(req, res, server, session) {

    res.sendFile(__dirname + "/views/find.html");

    var io = socket(server);

    io.use(sharedSession(session, {
        autoSave: true

All the parameters passed to the main function seemed when I console.log'd them, so I don't think it's that. Any help on why this error occurs would be much appreciated. Thanks.


Thành viên BQT
You also have to middleware session into express app after that you can use the sharedSessionmiddleware.

Correct way

var app = require('express')(),
  server  = require("http").createServer(app),
  io = require("")(server),
  session = require("express-session")({
    secret: "my-secret",
    resave: true,
    saveUninitialized: true
  sharedsession = require("");

// Attach session

// Share session with io sockets

Reference to official documentation -

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Chủ Đề Xem Nhiều