我应该如何在node.js上实现会话存储

发布于 2024-09-05 21:13:35 字数 177 浏览 1 评论 0原文

我正在创建 josi,一个 Node.js 的 Web 框架。我想添加会话存储。实现这一点的最佳方法是什么?我假设它可能必须基于 cookie,但我有兴趣知道是否有任何其他框架有不同的方法。

I'm creating josi, a web framework for node.js. And I'd like to add session storage. What would be the best way to implement this? I'm assuming it probably has to be cookie based, but I'm interested in knowing if any other frameworks have a different approach.

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

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

发布评论

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

评论(2

画▽骨i 2024-09-12 21:13:35

几天前我看了乔西。非常好的作品!

除了基于 cookie 之外,您还可以使用臭名昭著的会话令牌(例如 JSESSIONIDPHPSESSIDASPSESSIONID)并将它们放入隐藏表单或 URL 查询中细绳。

饼干确实是最好的选择。他们非常适合这份工作。

I had a look at josi a few days ago. Very nice work!

Other than cookie based, you could use infamous session tokens (e.g. JSESSIONID, PHPSESSID and ASPSESSIONID) and put them in hidden forms or the URL query string.

Cookies are really the best option. They work perfectly for the job.

空宴 2024-09-12 21:13:35

您总是需要以某种方式引用服务器会话,cookie 是此类内容的事实上的标准。

会话在服务器端的存储方式通常取决于您...我真的很喜欢 PHP 的 session_start(); 方法,它为您完成所有会话存储和 cookie 设置。

例如,PHP 将会话数据存储在文件中,使其跨平台(所有平台都有磁盘存储 API)。其他会话机制使用 MySQL 等关系数据库,但这并不是真正的跨平台,除非您想针对这些类型的用户。

You always need to reference the server session somehow, cookies are the de-facto standard for this sort of stuff.

How the session is stored on the server side is usually up to you... I really like PHP's approach with session_start(); which does all the session storage and cookies setting for you.

PHP for example stores the session data in a file, making it cross-platform (all platform's have disk storage APIs). Other session mechanisms use a relational-database like MySQL, but that's not really cross-platform unless you want to target those type of users.

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