dr5648 2014-01-28 12:40
浏览 44
已采纳

PHP SESSION重置过多的数据

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条回答 默认 最新

  • doulidai6316 2014-01-28 17:47
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?