>在没有显着影响性能的情况下,我们可以在会话中拥有多大的对象?
>我们可以在cookie中存储多大的对象?
>还有其他选择(除了从我们的数据库中检索数据)吗?
解决方法
6.3 Implementation Limits
Practical user agent implementations have limits on the number and
size of cookies that they can store. In general,user agents’ cookie
support should have no fixed limits. They should strive to store as
many frequently-used cookies as possible. Furthermore,general-use
user agents should provide each of the following minimum capabilities
individually,although not necessarily simultaneously:
at least 300 cookies
at least 4096 bytes per cookie (as measured by the size of the
characters that comprise the cookie non-terminal in the Syntax
description of the Set-Cookie header)at least 20 cookies per unique host or domain name
如果您的会话数据没有价值(例如“在重启时不应该丢失”),请考虑将其存储在memcached中.这非常快,并且只是为了获取会话数据而避免访问数据库.您可能实际上想要考虑使用两者的混合:您可以创建一个包含会话ID和登录信息的小cookie.然后丢失服务器端会话不会导致用户退出,因此影响会非常小.