Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP SESSION resets with too much data

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

like image 877
Kelu Thatsall Avatar asked Mar 20 '26 03:03

Kelu Thatsall


1 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 to Mediumtext (16MB). If someone needs even more data in their sessions they might want to use Longtext (4GB).

like image 117
Kelu Thatsall Avatar answered Mar 22 '26 18:03

Kelu Thatsall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!