source: trunk/phpgwapi/inc/adodb/tests/testsessions.php @ 34

Revision 34, 2.1 KB checked in by niltonneto, 17 years ago (diff)

Versão nova do ADODB (4.5 para 4.95)

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2
3/*
4V4.80 8 Mar 2006  (c) 2000-2007 John Lim (jlim#natsoft.com.my). 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'] = 99;
27$db = 'postgres';
28
29#### CONNECTION
30switch($db) {
31case 'oci8':
32        $options['table'] = 'adodb_sessions2';
33        ADOdb_Session::config('oci8', '', 'jcollect', 'natsoft', '',$options);
34        break;
35
36case 'postgres':
37        ADOdb_Session::config('postgres', 'localhost', 'tester', 'test', 'test',$options);
38        break;
39       
40case 'mysql':
41default:
42        ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options);
43        break;
44
45
46}
47       
48
49       
50#### SETUP NOTIFICATION
51        $USER = 'JLIM'.rand();
52        $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire');
53
54        adodb_session_create_table();
55        session_start();
56
57        adodb_session_regenerate_id();
58       
59### SETUP SESSION VARIABLES
60        if (empty($_SESSION['MONKEY'])) $_SESSION['MONKEY'] = array(1,'abc',44.41);
61        else $_SESSION['MONKEY'][0] += 1;
62        if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1;
63
64       
65### START DISPLAY
66        print "<h3>PHP ".PHP_VERSION."</h3>";
67        print "<p><b>\$_SESSION['AVAR']={$_SESSION['AVAR']}</b></p>";
68       
69        print "<hr /> <b>Cookies</b>: ";
70        print_r($_COOKIE);
71       
72        var_dump($_SESSION['MONKEY']);
73       
74### RANDOMLY PERFORM Garbage Collection
75### In real-production environment, this is done for you
76### by php's session extension, which calls adodb_sess_gc()
77### automatically for you. See php.ini's
78### session.cookie_lifetime and session.gc_probability
79
80        if (rand() % 5 == 0) {
81       
82                print "<hr /><p><b>Garbage Collection</b></p>";
83                adodb_sess_gc(10);
84               
85                if (rand() % 2 == 0) {
86                        print "<p>Random session destroy</p>";
87                        session_destroy();
88                }
89        }
90?>
Note: See TracBrowser for help on using the repository browser.