表达 mysql 会话

发布于 2024-11-07 17:38:04 字数 85 浏览 2 评论 0原文

我找不到将 mysql 中存储的会话与express和node.js一起使用的好方法。有人有一些模块的技巧或实现这一目标的方法吗?

提前致谢

I cant find a good way to use sessions stored in mysql with express and node.js. Anyone has some tips of modules or a way to achieve this?

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一影成城 2024-11-14 17:38:04

我创建了一个非常简单的 MySQL 会话存储,名为 connect-mysql-session。如果您已经有一个 MySQL 数据库并且想用它来持久化会话,那么这会很方便。通过 npm 安装它:

[sudo] npm install [-g] connect-mysql-session

I've created a very simple MySQL session store called connect-mysql-session. This is handy if you already have a MySQL database handy and want to use it to persist sessions. Install it via npm with:

[sudo] npm install [-g] connect-mysql-session
随梦而飞# 2024-11-14 17:38:04

据我所知,目前有七个用于连接(express 在其上运行)的会话连接管理中间件:

express-session(与express 捆绑,使用 MemoryStore)

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

connect-mongodb https://github.com/masylum/connect-mongodb

connect-couchdb https://github.com/tdebarochez/connect-couchdb

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

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

cookie-sessions(在客户端 cookie 中存储会话)https://github.com/caolan/cookie-sessions

为了能够使用 Mysql 作为会话存储,有人需要为其创建一个连接中间件。 (connect-redis 只有 125 行,所以这可能不是一项艰巨的任务。)

There are currently seven session connection management middleware for connect (upon which express runs) that I am aware of:

express-session (bundled with express, uses MemoryStore)

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

connect-mongodb https://github.com/masylum/connect-mongodb

connect-couchdb https://github.com/tdebarochez/connect-couchdb

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

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

cookie-sessions (stores sessions in client-side cookies) https://github.com/caolan/cookie-sessions

In able to use Mysql as a session store, someone would need to create a connect middleware for it. (connect-redis is only 125 lines so it's probably not a herculean task.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文