forked from Dynom/SessionHandler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
48 lines (37 loc) · 1.09 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// Registering autoload for the D lib
spl_autoload_register('_D_autoload');
function _D_autoload($className) {
$path = str_replace('_', '/', $className) .'.php';
if (is_readable($path)) {
include $path;
}
}
// Config
$memcacheConfig = array(
'hostname' => 'localhost'
);
$mysqlConfig = array(
'table_name' => 'phpsession',
'username' => 'd',
'password' => 'd',
'database' => 'phpsession',
'hostname' => 'localhost',
);
ini_set('session.save_handler', 'user');
// Init the handler
$handler = new D_SessionHandler();
// Registering the drivers
// Note: Order matters ! (fifo)
$handler
->addDriver( new D_SessionDriver_Memcache($memcacheConfig) )
->addDriver( new D_SessionDriver_Mysql($mysqlConfig) );
session_start();
session_regenerate_id();
$_SESSION['time'] = time();
echo '<pre>';
var_dump(
$_SESSION,
session_id(),
$handler->getLastReadDriver()
);