1<?php
2require_once '../mplt.php';
3$timer = new mplt();
4require_once '../dalmp.php';
5# -----------------------------------------------------------------------------------------------------------------
6
7$db = new DALMP('utf8://dalmp:password@192.168.1.40:3306/dalmptest');
8
9/**
10 * name of the REF field global var
11 */
12define('DALMP_SESSIONS_REF', 'UID');
13/**
14 * to store sessions on mysql you need to pass the $db DALMP object
15 */
16$sessions = new DALMP_Sessions($db);
17
18/**
19 * here you can declare the user ID so later check how many users are logged in or also avoid users to login twice
20 */
21$uid = 1;
22$GLOBALS['UID'] = $uid;
23
24if ((mt_rand() % 10) == 0) {
25  $sessions->regenerate_id(4);  // always after your $GLOBALS
26}
27
28/**
29 * get the REF stored on DB or Cache
30 */
31$rs = $sessions->getSessionRef($uid);
32echo '<pre>';
33print_r($rs);
34echo '</pre>';
35echo $db->isCli(1);
36
37/**
38 * delete the REF stored on DB or Cache
39 */
40$rs = $sessions->delSessionRef(1);
41echo $db->isCli(1);
42@$_SESSION['test']++;
43echo $_SESSION['test'];
44echo $db->isCli(1);
45
46# -----------------------------------------------------------------------------------------------------------------
47echo PHP_EOL,str_repeat('-', 80),PHP_EOL,'Time: ',$timer->getPageLoadTime(),' - Memory: ',$timer->getMemoryUsage(1),PHP_EOL,str_repeat('-', 80),PHP_EOL;
48