Documentation TYPO3 par Ameos |
00001 <?php 00002 00003 /* 00004 V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. 00005 Released under both BSD license and Lesser GPL library license. 00006 Whenever there is any discrepancy between the two licenses, 00007 the BSD license will take precedence. 00008 Set tabs to 4 for best viewing. 00009 00010 Latest version is available at http://adodb.sourceforge.net 00011 */ 00012 00013 function NotifyExpire($ref,$key) 00014 { 00015 print "<p><b>Notify Expiring=$ref, sessionkey=$key</b></p>"; 00016 } 00017 00018 //------------------------------------------------------------------- 00019 00020 error_reporting(E_ALL); 00021 00022 00023 ob_start(); 00024 include('../session/adodb-cryptsession2.php'); 00025 00026 $options['debug'] = 99; 00027 $db = 'postgres'; 00028 00029 #### CONNECTION 00030 switch($db) { 00031 case 'oci8': 00032 $options['table'] = 'adodb_sessions2'; 00033 ADOdb_Session::config('oci8', '', 'jcollect', 'natsoft', '',$options); 00034 break; 00035 00036 case 'postgres': 00037 ADOdb_Session::config('postgres', 'localhost', 'tester', 'test', 'test',$options); 00038 break; 00039 00040 case 'mysql': 00041 default: 00042 ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options); 00043 break; 00044 00045 00046 } 00047 00048 00049 00050 #### SETUP NOTIFICATION 00051 $USER = 'JLIM'.rand(); 00052 $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire'); 00053 00054 adodb_session_create_table(); 00055 session_start(); 00056 00057 adodb_session_regenerate_id(); 00058 00059 ### SETUP SESSION VARIABLES 00060 if (empty($_SESSION['MONKEY'])) $_SESSION['MONKEY'] = array(1,'abc',44.41); 00061 else $_SESSION['MONKEY'][0] += 1; 00062 if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1; 00063 00064 00065 ### START DISPLAY 00066 print "<h3>PHP ".PHP_VERSION."</h3>"; 00067 print "<p><b>\$_SESSION['AVAR']={$_SESSION['AVAR']}</b></p>"; 00068 00069 print "<hr /> <b>Cookies</b>: "; 00070 print_r($_COOKIE); 00071 00072 var_dump($_SESSION['MONKEY']); 00073 00074 ### RANDOMLY PERFORM Garbage Collection 00075 ### In real-production environment, this is done for you 00076 ### by php's session extension, which calls adodb_sess_gc() 00077 ### automatically for you. See php.ini's 00078 ### session.cookie_lifetime and session.gc_probability 00079 00080 if (rand() % 5 == 0) { 00081 00082 print "<hr /><p><b>Garbage Collection</b></p>"; 00083 adodb_sess_gc(10); 00084 00085 if (rand() % 2 == 0) { 00086 print "<p>Random session destroy</p>"; 00087 session_destroy(); 00088 } 00089 } 00090 ?>