I'm trying to restart and keep the session alive using nodemon, but when you restart the session is destroyed.. I wonder if there is any way to keep living with nodemon or other node js library session.
scripts ": { // "Start": "node ./bin/www" "start": "nodemon ./bin/www" }
Thanks for your time
In order to persist session, there are two approaches:
Use some persistent store
Use JSON Web Tokens
For implementing persistent session, you can use MongoDB session store or Redis Session store.
If you want to use redis then make use of connect-redis npm package. If you want to use MongoDb as session store then make use of connect-mongo npm package
There are some settings which you need to do in you app.js/server.js. In one of my demo i am using Redis Session store with PassportJS, if you are looking for example, feel free to look here.
If you want to use JSON web tokens, there are many different implementations available. I am using jsonwebtoken. I implemented this using PassportJS, ExpressJS and AngularJS in front End. For example look here. Tokens are encoded and stored in browser's local storage with a secret key.
I would suggest you to go for JSON web tokens, read it in detail because that is how most of the major web apps are developed. Let me know if you need more help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With