123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- require 'SharedConfigurations.php';
- if (!interface_exists('SessionHandlerInterface')) {
- die("ATTENTION: the session handler implemented by Predis needs PHP >= 5.4.0 or a polyfill ".
- "for \SessionHandlerInterface either provided by you or an external package.\n");
- }
- $client = new Predis\Client($single_server, array('prefix' => 'sessions:'));
- $handler = new Predis\Session\Handler($client, array('gc_maxlifetime' => 5));
- $handler->register();
- session_id('example_session_id');
- session_start();
- if (isset($_SESSION['foo'])) {
- echo "Session has `foo` set to {$_SESSION['foo']}", PHP_EOL;
- } else {
- $_SESSION['foo'] = $value = mt_rand();
- echo "Empty session, `foo` has been set with $value", PHP_EOL;
- }
|