I’ve created a test file to find out how big my session can be.
It’s something like this:
print_r($_SESSION);
$test = array();
for ($i=0;$i<3320;$i++) {
$test[$i] = "test:)";
}
$size = mb_strlen(serialize($test), '8bit');
echo "Size: $size";
$_SESSION['test'] = $test;
When I do this, the $_SESSION['test']
gets reset (its value is nothing). When I’m doing this in a lesser for
(3319 times) or for a shorter string, then it’s working fine. Size value is in this case 65279 bytes. I figure I should be able to change some setting in php.ini to be able to store more data, but which one would that be?
Just for your information – I don’t care about performance, there shouldn’t be really more than one person at the time using the script and it’s for some synchronization with another server so the user will need to wait anyway. I’m just looking for an information how can I store more data in the $_SESSION
table.
My PHP version is 5.2.17 and I’m using osCommerce (really old one).
2
Answers
Sorry for misguiding guys. It seems the reason for that was that I was storing the session in database (using osCommerce). Database field which holds the value of session was set to be of type
Text
which is 64KB. I've changed it toMediumtext
(16MB). If someone needs even more data in their sessions they might want to useLongtext
(4GB).You cannot set size to a session in php.
you can, however, set the memory limit [I advise you to be careful with limitations in code if doing this].
http://ca.php.net/manual/en/ini.core.php#ini.memory-limit