Sessions in Node JS

前端 未结 10 806
北海茫月
北海茫月 2021-01-07 23:46

How can I maintain my SESSIONS in Node JS ? E.g I want to store UserID in SESSION using Node Js. How can I do that in Node JS ? And can I use that Node JS SESSION in PHP too

10条回答
  •  抹茶落季
    2021-01-08 00:15

    You could use express-session middleware. Combine it with connect-redis or connect-mongo to store your sessions inside a database and save memory if memory is valuable to you (like in a cloud setup).

    https://github.com/expressjs/session

    https://www.npmjs.com/package/express-sessions

    If you store it in say mongodb , use php mongo driver to pick it up from there.

提交回复
热议问题