1<?php
2
3/*
4V4.80 8 Mar 2006  (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
5  Released under both BSD license and Lesser GPL library license.
6  Whenever there is any discrepancy between the two licenses,
7  the BSD license will take precedence.
8  Set tabs to 4 for best viewing.
9
10  Latest version is available at http://adodb.sourceforge.net
11*/
12
13function NotifyExpire($ref,$key)
14{
15	print "<p><b>Notify Expiring=$ref, sessionkey=$key</b></p>";
16}
17
18//-------------------------------------------------------------------
19
20error_reporting(E_ALL);
21
22
23ob_start();
24include('../session/adodb-cryptsession2.php');
25
26$options['debug'] = 1;
27$db = 'oci8';
28
29#### CONNECTION
30switch($db) {
31case 'oci8':
32	$options['table'] = 'adodb_sessions2';
33	ADOdb_Session::config('oci8', '', 'jcollect_bkrm', 'natsoft', '',$options);
34	break;
35
36case 'postgres':
37	$options['table'] = 'sessions2';
38	ADOdb_Session::config('postgres', 'localhost', 'tester', 'test', 'test',$options);
39	break;
40
41case 'mysql':
42default:
43	$options['table'] = 'sessions2';
44	ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options);
45	break;
46
47
48}
49
50
51
52#### SETUP NOTIFICATION
53	$USER = 'JLIM'.rand();
54	$ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire');
55
56	adodb_session_create_table();
57	session_start();
58
59	adodb_session_regenerate_id();
60
61### SETUP SESSION VARIABLES
62	if (empty($_SESSION['MONKEY'])) $_SESSION['MONKEY'] = array(1,'abc',44.41);
63	else $_SESSION['MONKEY'][0] += 1;
64	if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1;
65
66
67### START DISPLAY
68	print "<h3>PHP ".PHP_VERSION."</h3>";
69	print "<p><b>\$_SESSION['AVAR']={$_SESSION['AVAR']}</b></p>";
70
71	print "<hr /> <b>Cookies</b>: ";
72	print_r($_COOKIE);
73
74	var_dump($_SESSION['MONKEY']);
75
76### RANDOMLY PERFORM Garbage Collection
77### In real-production environment, this is done for you
78### by php's session extension, which calls adodb_sess_gc()
79### automatically for you. See php.ini's
80### session.cookie_lifetime and session.gc_probability
81
82	if (rand() % 5 == 0) {
83
84		print "<hr /><p><b>Garbage Collection</b></p>";
85		adodb_sess_gc(10);
86
87		if (rand() % 2 == 0) {
88			print "<p>Random own session destroy</p>";
89			session_destroy();
90		}
91	} else {
92		$DB = ADODB_Session::_conn();
93		$sessk = $DB->qstr('%AZ'.rand().time());
94		$olddate = $DB->DBTimeStamp(time()-30*24*3600);
95		$rr = $DB->qstr(rand());
96		$DB->Execute("insert into {$options['table']} (sesskey,expiry,expireref,sessdata,created,modified) values ($sessk,$olddate, $rr,'',$olddate,$olddate)");
97	}
98?>