会话变量是否有限制? [英] Are there limits for session variables?

查看:78
本文介绍了会话变量是否有限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,会话变量是否有限制(如果有的话),或者它们被视为常用变量并且可以存储相等数量的数据?

As the title says, are there limits (if any) for session variables or they're considered as usual variables and can store equal amount of data?

我正在寻找除最大长度,最大值等变量类型之外是否还有其他限制.

I'm looking if there are any other limits aside from variable type ones like max length, max values and so on.

P.S.如果问题不清楚,请告诉我.

P.S. If the question is unclear, please let me know.

提前谢谢!

推荐答案

正如@Thariama所说,变量数量没有限制;此外,会话中可以存储的数据量没有限制(我看到会话的大小为几十MB).

As @Thariama said, there's no limit on the number of variables; also, there's no limit on the amount of data you can store in a session (I've seen sessions tens of MB in size).

随着会话大小的增加,您会遇到各种奇怪的问题:PHP 5将整个会话反序列化到session_start()的内存中(使用默认的会话处理程序-您可以

As the size of a session gets larger, you'll run into various quirks though: PHP 5 deserializes the whole session into memory at session_start() (using the default session handler - you can make you own solution, of course); with a 20 MB session and 50 concurrent users, your scripts start to be severely limited by disk access speeds (a.k.a. "script startup is slow as molasses" - the sessions alone would be hogging a GB of RAM); in the end, we dedicated a box to keep as many sessions as possible in its RAM, and the frontend boxes accessed them over NFS (although it helped in our case, this may be overkill for you).

请注意,对于磁盘上的许多并发用户和会话存储,会话临时文件的数量可能会引起文件系统限制的问题(例如,在遇到stat()

Note that for many concurrent users and session storage on disk, the number of session temporary files may cause problems with filesystem limits (e.g. how many files can be in one directory before you run into problems with stat() performance), or other limits (we once found the hard way that a box was configured to only allow 4096 open files at the same time). None of this is really session-specific, but can be triggered by session handling.

这篇关于会话变量是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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