|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61332 WinCache Session don't save an array if element count not changed just a value
Submitted: 2012-03-09 00:32 UTC Modified: 2015-08-27 22:30 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: haliferi at freemail dot hu Assigned: ericsten (profile)
Status: Closed Package: WinCache (PECL)
PHP Version: 5.3.10 OS: Windows Server 2008 R2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: haliferi at freemail dot hu
New email:
PHP Version: OS:


 [2012-03-09 00:32 UTC] haliferi at freemail dot hu
I am running PHP 5.3.10 x86 (API220090626,NTS,VC9) on IIS7.5 with Wincache Version 1.1.0630.0, opcode cache enabled, session works in all other cases.

I have an array in the session, but if i unset the first item, and add a new to the and, then Wincache won't save it to the session in my case. But if i modify the item count: unset the first 2 element, then it will be saved. The other session variables are not affected, objects, ints are successfully saved to the session.

I tested it with WinCache 1.2.427, 1.2.614 and 1.2.1208 too, but nothing changed.

Test script:
$_SESSION['chresp'] = array( // already saved in the session
'dfjkg6' => 
array('a' => 'gdfg7df887', 'b' => 'h34g3436sh', 'valid' => 1331196464),
'5gf5av' => 
array('a' => 'tu4dcff3d3', 'b' => 'gh323fghd3', 'valid' => 1331196465),
's7g35b' => 
array('a' => '32a4djg2sa', 'b' => 'ib78m37fdj', 'valid' => 1331196466));

if (count($_SESSION['chresp']) > 2)

$_SESSION['chresp']['kjhg7f'] =
  array('a' => 'kgkj3dfkg7', 'b' => 'as88f4jk4jk', 'valid' => 1331196467);

// i can see the new value here, but the next refresh the init array appears again

Expected result:
The new array has saved to the session.

Actual result:
If i run the test script standalone, it works, but as i run it in my project, it produces the bug, maybe another session, or wincache user cache reads/writes have makes this effect together.

But if i switch to any other session handler in the php.ini (memcache, simple file), it solves the problem.

The most weird is that modifying the element count makes Wincache to save it.

There is no error, warning, everything is in order, just the array won't be updated in the wincache session store.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-20 16:30 UTC]
-Assigned To: +Assigned To: ericsten
 [2015-08-27 22:30 UTC]
-Status: Assigned +Status: Closed
 [2015-08-27 22:30 UTC]
I wrote a script to simulate this issue with the session array and tested it with PHP7 + WinCache on x64.  I was unable to repro the issue.

Test Script:

function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, strlen($characters) - 1)];
    return $randomString;


$sess_data = $_SESSION['chresp'];

if (NULL == $sess_data)
  $sess_data = array( 
    'dfjkg6' => 
       array('a' => 'gdfg7df887', 'b' => 'h34g3436sh', 'valid' => 1331196464),
    '5gf5av' => 
      array('a' => 'tu4dcff3d3', 'b' => 'gh323fghd3', 'valid' => 1331196465),
    's7g35b' => 
      array('a' => '32a4djg2sa', 'b' => 'ib78m37fdj', 'valid' => 1331196466));

  echo("Original array \$sess_data:\n");

  $_SESSION['chresp'] = $sess_data;
  echo("Session 'chresp' already exists!\n");

echo("fetched from \$_SESSION['chresp']\n");

if (count($_SESSION['chresp']) > 2)
$new_element = generateRandomString(6);
$_SESSION['chresp'][$new_element] =
  array('a' => generateRandomString(), 'b' => generateRandomString(), 'valid' => 1331196467);

echo("fetched from \$_SESSION['chresp'] after array_shift'ing and adding new element $new_element\n");


PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Feb 23 13:01:26 2019 UTC