[Sessions] Support MongoDB as session storage
See original GitHub issueIssue
We currently have TypeORMStore
and RedisStore
to store sessions in SQL and Redis databases. It is annoying for people using MongoDB with FoalTS. We should also support MongoDB
session storage.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Storing sessions with connect-mongo in MongoDB.
A session can temporarily store information related to the activities of the user while connected. For example, you can store a unique ...
Read more >Best Session Storage Middleware for Express + MongoDB
Sessions work by matching a session ID inside a cookie to an ID in that database. So if you use it for a...
Read more >Using MongoDb for Quick Session Storage with connect ...
Set up quick session storage for production environments in Express with connect-mongo and keep the focus on your application logic.
Read more >Using MongoDB as a Session Store (How To) - Treehouse
In this lesson learn how to use a MongoDB-based data store for your session variables, which provides a scalable solution for a production...
Read more >Server Sessions — MongoDB Manual
MongoDB's server sessions, or logical sessions, are the underlying framework used by client sessions to support Causal Consistency and retryable writes.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Important! I’m assuming that your clients are sending the session token either via the
Authorization
header or cookies as described in the documentationYou seem to be doing everything correctly regarding the session store setup. You are getting undefined because
foal
doesn’t support mongodb session store natively. You have to use the old and manual “express-session” way of managing sessions. This very issue exists to address that.But while we await its implementation from @LoicPoullain , you can get access to the current request through
context.request
which you can treat as an express request instance socontext.request.session
should give you the current session.Let me know if you need more assistance!
Feature added in v1.1.0