Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Logout All sessions for an account in express-session, postgresql (connect-pg-simple)

I was wondering how one would create a route to logout all sessions (not just the current one) for a user when using express-session and connect-pg-simple as a session store.

I have the sessions table name set as user_sessions and have previously been able to achieve this using the mysql store on a previous project, which went something like this;

const db = require("../db/connection");

exports.logoutAllDevices = async (user_id) => {
// req.logout(); -- I called this in the controller just before, left it here to show its been called
let logoutAllQuery = 'DELETE FROM user_sessions WHERE JSON_EXTRACT(`data`, "$.passport.user") = $1;';
await db.query(logoutAllQuery, [user_id]);
return;
};

which i found before and the idea was to destroy all sessions related to that user as well as calling the req.logout() function.

However, I can't get any solution to work with this postgres store. Help is appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!