Database session support in nodejs/express

2019-03-11 12:19发布

问题:

Does expressjs/nodejs have support (via a module?) for database sessions? I come from the world of PHP/CodeIgniter and I've enjoyed the features of storing session data in a mysql database table.

Is this approach used with nodejs web apps?

回答1:

Yes.

Redis

  • https://github.com/visionmedia/connect-redis

MySQL

  • https://github.com/mren/connect-session-mysql Broken Link
  • https://github.com/CarnegieLearning/connect-mysql-session Old, Unsupported
  • https://github.com/chill117/express-mysql-session

PostgreSQL

  • https://github.com/jebas/connect-pg

MongoDB

  • https://github.com/kcbanner/connect-mongo
  • https://github.com/bartt/connect-session-mongo
  • https://github.com/donpark/session-mongoose
  • https://github.com/masylum/connect-mongodb

Memcached

  • https://github.com/balor/connect-memcached

CouchDB

  • https://github.com/tdebarochez/connect-couchdb
  • https://github.com/eldios/connect-cradle

Riak

  • https://github.com/frank06/connect-riak

SQLite

  • https://github.com/tnantoka/connect-sqlite
  • https://github.com/pkrumins/supermarket-cart

File-based

  • https://github.com/odogono/connect-session-file
  • https://github.com/tnantoka/connect-fs

Kyoto-cabinet

  • https://github.com/kazupon/connect-kyoto

Azure

  • https://github.com/pofallon/connect-bluesky

nStore

  • https://github.com/creationix/nstore-session

node-dirty

  • https://github.com/mmichelli/connect-dirty

VOC (?)

  • https://github.com/triAGENS/SessionVoc-Connect.js

It's quite simple to implement your own, see documentation here.