$storage->
close();
$storage->
open('', 'sid'
);
$storage->
read('gc_id'
);
ini_set('session.gc_maxlifetime', -1
); // test that you can set lifetime of a session after it has been read
$storage->
write('gc_id', 'data'
);
$storage->
close();
$this->
assertEquals(2,
$pdo->
query('SELECT COUNT(*) FROM sessions'
)->
fetchColumn(), 'No session pruned because gc not called'
);
$storage->
open('', 'sid'
);
$data =
$storage->
read('gc_id'
);
$storage->
gc(-1
);
$storage->
close();
ini_set('session.gc_maxlifetime',
$previousLifeTime);
$this->
assertSame('',
$data, 'Session already considered garbage, so not returning data even if it is not pruned yet'
);
$this->
assertEquals(1,
$pdo->
query('SELECT COUNT(*) FROM sessions'
)->
fetchColumn(), 'Expired session is pruned'
);
} public function testGetConnection() { $storage =
new PdoSessionHandler($this->
getMemorySqlitePdo());