Changeset 34 for trunk/phpgwapi/inc/adodb/tests/testsessions.php
- Timestamp:
- 06/29/07 15:17:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/adodb/tests/testsessions.php
r2 r34 2 2 3 3 /* 4 V4. 51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.4 V4.80 8 Mar 2006 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 5 5 Released under both BSD license and Lesser GPL library license. 6 6 Whenever there is any discrepancy between the two licenses, … … 18 18 //------------------------------------------------------------------- 19 19 20 error_reporting(E_ALL); 21 22 23 ob_start(); 24 include('../session/adodb-cryptsession2.php'); 25 26 $options['debug'] = 99; 27 $db = 'postgres'; 28 29 #### CONNECTION 30 switch($db) { 31 case 'oci8': 32 $options['table'] = 'adodb_sessions2'; 33 ADOdb_Session::config('oci8', '', 'jcollect', 'natsoft', '',$options); 34 break; 35 36 case 'postgres': 37 ADOdb_Session::config('postgres', 'localhost', 'tester', 'test', 'test',$options); 38 break; 20 39 21 #### CONNECTION 22 if (1) { 23 $ADODB_SESSION_DRIVER='oci8'; 24 $ADODB_SESSION_CONNECT=''; 25 $ADODB_SESSION_USER ='scott'; 26 $ADODB_SESSION_PWD ='natsoft'; 27 $ADODB_SESSION_DB =''; 28 } else { 29 $ADODB_SESSION_DRIVER='mysql'; 30 $ADODB_SESSION_CONNECT='localhost'; 31 $ADODB_SESSION_USER ='root'; 32 $ADODB_SESSION_PWD =''; 33 $ADODB_SESSION_DB ='xphplens_2'; 40 case 'mysql': 41 default: 42 ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options); 43 break; 44 45 34 46 } 35 47 36 ### TURN DEBUGGING ON37 $ADODB_SESS_DEBUG = true;38 48 39 49 … … 42 52 $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire'); 43 53 44 45 #### INIT 46 ob_start(); 47 error_reporting(E_ALL); 48 include('../session/adodb-cryptsession.php'); 54 adodb_session_create_table(); 49 55 session_start(); 50 56 51 57 adodb_session_regenerate_id(); 58 52 59 ### SETUP SESSION VARIABLES 53 $HTTP_SESSION_VARS['MONKEY'] = array('1','abc',44.41); 54 if (!isset($HTTP_GET_VARS['nochange'])) @$HTTP_SESSION_VARS['AVAR'] += 1; 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; 55 63 56 64 57 65 ### START DISPLAY 58 66 print "<h3>PHP ".PHP_VERSION."</h3>"; 59 print "<p><b>\$ HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</b></p>";67 print "<p><b>\$_SESSION['AVAR']={$_SESSION['AVAR']}</b></p>"; 60 68 61 print "<hr> <b>Cookies</b>: "; 62 print_r($HTTP_COOKIE_VARS); 69 print "<hr /> <b>Cookies</b>: "; 70 print_r($_COOKIE); 71 72 var_dump($_SESSION['MONKEY']); 63 73 64 74 ### RANDOMLY PERFORM Garbage Collection 65 if (rand() % 10 == 0) { 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) { 66 81 67 print "<hr ><p><b>Garbage Collection</b></p>";82 print "<hr /><p><b>Garbage Collection</b></p>"; 68 83 adodb_sess_gc(10); 69 84 70 print "<p>Random session destroy</p>"; 71 session_destroy(); 85 if (rand() % 2 == 0) { 86 print "<p>Random session destroy</p>"; 87 session_destroy(); 88 } 72 89 } 73 90 ?>
Note: See TracChangeset
for help on using the changeset viewer.