CookieSession in Express.js is successfully integrated with Passport, however, the maxAge parameter seems to be malfunctioning

I've integrated Passport-Facebook and CookieSession for user authentication on my web application. Everything is functioning smoothly, but I'm facing an issue with setting the session expiration time.

app.use(cookieSession({
    secret: 'I love stackoverflow',
    cookie: { maxAge: 60000 } // Setting it to 1 minute, but it's not working.
}));
passport.serializeUser(...);
passport.deserializeUser(...);
passport.use(new FacebookStrategy(...));
app.use(passport.initialize());
app.use(passport.session());

I'm utilizing express 4.9. Does anyone know what might be causing this problem? When I switch from cookieSession to session, everything works perfectly. However, I prefer not to store cookies on my server, hence why I want to stick with cookieSession.

Is there a compatibility issue between CookieSession maxAge and Passport?

Answer №1

Regrettably, I find myself providing the solution to my own query.

The issue was resolved by implementing

cookie: { maxage: 60000}

It is important to note that it should be referred to as maxage instead of maxAge.

I suggest that the creator of cookieSession consider using a consistent naming convention with other packages. Hopefully my solution can assist you if you encounter a similar dilemma.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When attempting to install grunt on nodeenv with npm, you may encounter a findup-sync error

After setting up a node virtualenv with nodeenv, I execute source /bin/activate to switch to the correct directory, update npm, and run npm install -g grunt or npm install -g grunt-cli, but I continue to encounter the same error: npm ERR! Linux 3.13.0-53 ...

Setting up a node application on Digital Ocean using PM2 for deployment

As I attempt to direct a domain to my node app, I realize that it utilizes port 80 and I am experimenting with PM2 to launch my node app as a service. When I input pm2 start app.js, I receive a series of incomprehensible characters that appear like this: ...

Struggling to pass Chai tests with Node and Express.js when trying to handle POST requests

Working through a Chai testing exercise and struggling to pass the POST route tests. Encountering two specific errors: 1) Todo API: POST /v1/todos Issue with creating and returning new todo using valid data: Header 'location' should ...

Are JWT authentication methods secure and how do they help protect against CORS vulnerabilities?

I have recently implemented token-based authentication in my project rather than using cookie-session based authentication. With JSON Web Tokens (JWT), every time I send a request to the server, I attach the token in the headers and validate it against t ...

Attempting to transform a mysql timestamp into standard time by utilizing the strtotime function

strtotime($_SESSION['starting_timestamp']) I attempted to convert the MySQL timestamp stored as $_SESSION['starting_timestamp'], which has a value of 1422094831. However, when I applied strtotime function on it, it did not return any va ...

Tips for finding text matches without considering special characters such as commas or other punctuation symbols

How can I search for "HollandPark" or "Holland Park, Notting Hill" or "holland park notting hill" in MongoDB to match with the text "Holland Park, Notting Hill"? ...

What kinds of tasks are most suitable for execution in the back-end system?

As I delved into understanding the distinction between backend and frontend operations, a new question popped up in my mind - when should I definitively leave certain tasks for the backend to handle? Taking Node.js with Express as an example, how do I dete ...

Issues have arisen regarding the establishment of live connections with Elasticsearch when integrating it with nodejs

I'm encountering an issue while trying to establish connections with Elasticsearch. var elasticsearch = require('elasticsearch'); var client = new elasticsearch.Client({ host: 'localhost:9200', ...

Error in creating the database: Outcome is not defined

I am currently working on developing a basic nodejs program using express and mysql. const express = require('express'); const mysql = require('mysql'); const db = mysql.createConnection({ host : 'localhost', user : ...

Increased capacities with content and acceptance encoding headers

Consider the following scenario: I send a POST request from the client server to a REST API with a payload size of 20-30MB, where the content is gzip compressed at the network level due to the request header configuration. Do I also need to enable gzip c ...

What is the proper way to access object properties in EJS?

My server has an express API to retrieve food items and I want to display their names on my ejs index file. In order to fetch the data, I have the following code in my server.js file: app.get('/', async (req, res) => { try { fetch ...

Are RSS and Atom the Same? Challenges Encountered in Retrieving and Parsing

$.ajax({ type: 'GET', url : 'http://examplewebsite.com/feeds/items/123456.atom', dataType : 'xml', error: function(xhr) { console.log('Failed to parse feed'); }, ...

Challenges arise when using node Serialport for writing data

My current project involves sending commands from a node server to an Arduino Mega board and receiving responses. Everything works smoothly when I limit the calls to SERIALPORT.write to once every 1000ms. However, if I attempt to increase the frequency, I ...

Facing issues with Google token authentication using Express and Passport

Recently, I created a REST api utilizing Express with Passport and the passport-google-token strategy for user authentication. Surprisingly, everything functions flawlessly when the server is running on localhost, but encounters issues on the live version ...

What is the process for incorporating synchronous tasks within an asynchronous function?

const fs = require('fs') const readline = require('readline') const stream = require('stream') const rl = readline.createInterface({ input: fs.createReadStream('logs.txt') }) var uniqueItems = new Set() // ASY ...

Compiling async code with generators in Typescript proves to be challenging

Scenario As I delve deeper into Typescript, I've come across the advice that blocking calls should not be made within asynchronous code. I have also found generators to be helpful in simplifying directory traversal and preventing stack overflow. ...

What are the steps to resolve a peer dependency problem with npm?

I am facing a conflict in my package.json file with the following modules: react-router requires react 0.13.x redbox-react requires react@>=0.13.2 || ^0.14.0-rc1 After running npm install react, I ended up with version <a href="/cdn-cgi/l/emai ...

Navigating through this object with PUG and Express: a step-by-step guide

I am currently working on a basic blockchain project to practice my skills with nodejs. I have created a blockchain object that consists of a block class, and now I want to loop through this object using pug. app.get('/', function(request, respon ...

What are some potential problems that could arise when making a POST request for signing authentication in a MERN stack using JWT?

I'm currently in the process of developing a social media application using the MERN stack. To ensure the functionality of the backend API, I am utilizing POSTMAN. Here is an overview of the dependencies outlined in the package.json file: { "na ...

Database connection error: Authentication protocol requested by server not supported

I have been struggling with the issue outlined in this link: MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client Even though I have tried following the recommendations, I am still encountering e ...