Connect / Express中的“会话”和“CookieSession”中间件有什么区别? [英] What is the difference between 'session' and 'cookieSession' middleware in Connect/Express?

查看:182
本文介绍了Connect / Express中的“会话”和“CookieSession”中间件有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Connect / Express捆绑有两个与会话相关的中间件。
有什么区别?我如何选择?

There are two session-related middlewares bundled with Connect/Express. What is the difference? How do I choose?

我假设会话< a>中间件与 cookieSession 中间件相同,但具有额外的存储机制。

I'm assuming that session middleware is the same as cookieSession middleware, but with an extra store mechanism.

推荐答案

会话中间件实现默认情况下,具有内存中存储的通用会话功能。它允许您指定其他存储格式。

The session middleware implements generic session functionality with in-memory storage by default. It allows you to specify other storage formats, though.

cookieSession中间件,另一方面,实现了支持cookie的存储(即,整个会话被序列化到cookie,而不仅仅是一个会话密钥,它应该只能在会话数据将保持相对较小。

The cookieSession middleware, on the other hand, implements cookie-backed storage (that is, the entire session is serialized to the cookie, rather than just a session key. It should really only be used when session data is going to stay relatively small.

这篇关于Connect / Express中的“会话”和“CookieSession”中间件有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆