Asked  7 Months ago    Answers:  5   Viewed   31 times

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. If the question is unclear, please let me know.

Thanks in advance!

 Answers

75

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).

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).

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.

Wednesday, March 31, 2021
 
AntoineB
answered 7 Months ago
24

The behavior you describe opposes the concept of a browser session. Why would a user want more than one session? Is it a matter of user access controls needing to be enforced? If so, assign users to logical groups and grant permissions to specific groups. Do users need to perform some action on behalf of other users? If so, design the website around that concept instead of trying to create multiple sessions for a single user.

If you really have to do this, you could do something horrible like pass along a query parameter (very insecure!) between pages to act as a session ID, bypassing the actual $_SESSION altogether and managing your own concept of a session. Again, this is not normal and will only lead to headaches/security issues in the future.

Wednesday, March 31, 2021
 
Kwadz
answered 7 Months ago
29

My suggestion from your previous question still stands: please compare session ids.

The solution might be as simple as your browser not accepting session cookies.

You retrieve the session id by calling session_id(). Do that right after session_start() it should give you a constant value if the session is the same. Otherwise for every request a new session is instantiated.

Also check C:wamptmp. A gazillion files in this directory might indicate fresh sessions for each request.

EDIT Since we've confirmed new sessions per request, it's time to find out whether session cookies are accepted. Check the settings of your browser and confirm that a cookie for your domain (I guess it's "localhost") with the name PHPSESSID can be found.

Tuesday, July 6, 2021
 
Niels
answered 4 Months ago
83

There's a high likelihood the Qt types distill down to one of the basic types for which numeric_limits are defined. Have you tried calling e.g., std::numeric_limits<qlonglong>::max()?

As MSalters points out, too, if the types are not builtin numeric_limits can still be specialized for them. If that were the case one would hope Qt would include them.

Sunday, August 22, 2021
 
rici
answered 2 Months ago
100

Are you sure it's a PHP issue? The MySQL TEXT field has a maximum size of 65535 characters. Make sure the text is actually in your database.

Tuesday, August 24, 2021
 
Ason
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :