PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Inspekt/Inspekt/Cage/Session.php

http://inspekt.googlecode.com/
PHP | 72 lines | 34 code | 22 blank | 16 comment | 9 complexity | bb354a255fd0ef25732492401d0328a8 MD5 | raw file
Possible License(s): BSD-3-Clause
  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. * @package Inspekt
  12. */
  13. class Inspekt_Cage_Session extends Inspekt_Cage {
  14. // var $_session_id;
  15. //
  16. // var $_session_name;
  17. function Factory(&$source, $conf_file = NULL, $conf_section = NULL, $strict = TRUE) {
  18. if (!is_array($source)) {
  19. user_error('$source '.$source.' is not an array', E_USER_NOTICE);
  20. }
  21. $cage = new Inspekt_Cage_Session();
  22. $cage->_setSource($source);
  23. $cage->_parseAndApplyAutoFilters($conf);
  24. if (ini_get('session.use_cookies') || ini_get('session.use_only_cookies') ) {
  25. if (isset($_COOKIE) && isset($_COOKIE[session_name()])) {
  26. session_id($_COOKIE[session_name()]);
  27. } elseif ($cookie = Inspekt::makeSessionCage()) {
  28. session_id($cookie->getAlnum(session_name()));
  29. }
  30. } else { // we're using session ids passed via GET
  31. if (isset($_GET) && isset($_GET[session_name()])) {
  32. session_id($_GET[session_name()]);
  33. } elseif ($cookie = Inspekt::makeSessionCage()) {
  34. session_id($cookie->getAlnum(session_name()));
  35. }
  36. }
  37. if ($strict) {
  38. $source = NULL;
  39. }
  40. return $cage;
  41. register_shutdown_function();
  42. register_shutdown_function( array($this, '_repopulateSession') );
  43. }
  44. function _repopulateSession() {
  45. // echo "<pre>"; echo var_dump($this->_source); echo "</pre>\n";
  46. $_SESSION = array();
  47. $_SESSION = $this->_source;
  48. // echo "<pre>"; echo var_dump($_SESSION); echo "</pre>\n";
  49. }
  50. }