/trunk/Inspekt/Inspekt/Cage/Session.php
PHP | 72 lines | 34 code | 22 blank | 16 comment | 9 complexity | bb354a255fd0ef25732492401d0328a8 MD5 | raw file
1<?php 2/** 3 * Inspekt Session Cage - main source file 4 * 5 * @author Chris Shiflett <chris@shiflett.org> 6 * @author Ed Finkler <coj@funkatron.com> 7 * 8 * @package Inspekt 9 */ 10 11 12/** 13 * @package Inspekt 14 */ 15class Inspekt_Cage_Session extends Inspekt_Cage { 16 17// var $_session_id; 18// 19// var $_session_name; 20 21 function Factory(&$source, $conf_file = NULL, $conf_section = NULL, $strict = TRUE) { 22 23 if (!is_array($source)) { 24 user_error('$source '.$source.' is not an array', E_USER_NOTICE); 25 } 26 27 $cage = new Inspekt_Cage_Session(); 28 $cage->_setSource($source); 29 $cage->_parseAndApplyAutoFilters($conf); 30 31 if (ini_get('session.use_cookies') || ini_get('session.use_only_cookies') ) { 32 if (isset($_COOKIE) && isset($_COOKIE[session_name()])) { 33 session_id($_COOKIE[session_name()]); 34 } elseif ($cookie = Inspekt::makeSessionCage()) { 35 session_id($cookie->getAlnum(session_name())); 36 } 37 } else { // we're using session ids passed via GET 38 if (isset($_GET) && isset($_GET[session_name()])) { 39 session_id($_GET[session_name()]); 40 } elseif ($cookie = Inspekt::makeSessionCage()) { 41 session_id($cookie->getAlnum(session_name())); 42 } 43 } 44 45 46 if ($strict) { 47 $source = NULL; 48 } 49 50 return $cage; 51 52 register_shutdown_function(); 53 54 register_shutdown_function( array($this, '_repopulateSession') ); 55 56 } 57 58 59 60 function _repopulateSession() { 61 62// echo "<pre>"; echo var_dump($this->_source); echo "</pre>\n"; 63 $_SESSION = array(); 64 65 $_SESSION = $this->_source; 66// echo "<pre>"; echo var_dump($_SESSION); echo "</pre>\n"; 67 68 } 69 70 71 72}