Session.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class LtSession
  3. {
  4. public $storeHandle;
  5. public $configHandle;
  6. public function __construct()
  7. {
  8. if (! $this->configHandle instanceof LtConfig)
  9. {
  10. if (class_exists("LtObjectUtil", false))
  11. {
  12. $this->configHandle = LtObjectUtil::singleton("LtConfig");
  13. }
  14. else
  15. {
  16. $this->configHandle = new LtConfig;
  17. }
  18. }
  19. }
  20. public function init()
  21. {
  22. if(!$sessionSavePath = $this->configHandle->get("session.save_path"))
  23. {
  24. $sessionSavePath = '/tmp/Lotus/session/';
  25. }
  26. if (!is_object($this->storeHandle))
  27. {
  28. ini_set('session.save_handler', 'files');
  29. if (!is_dir($sessionSavePath))
  30. {
  31. if (!@mkdir($sessionSavePath, 0777, true))
  32. {
  33. trigger_error("Can not create $sessionSavePath");
  34. }
  35. }
  36. session_save_path($sessionSavePath);
  37. }
  38. else
  39. {
  40. $this->storeHandle->conf = $this->configHandle->get("session.conf");
  41. $this->storeHandle->init();
  42. session_set_save_handler(
  43. array(&$this->storeHandle, 'open'),
  44. array(&$this->storeHandle, 'close'),
  45. array(&$this->storeHandle, 'read'),
  46. array(&$this->storeHandle, 'write'),
  47. array(&$this->storeHandle, 'destroy'),
  48. array(&$this->storeHandle, 'gc')
  49. );
  50. }
  51. //session_start();
  52. //header("Cache-control: private"); // to overcome/fix a bug in IE 6.x
  53. }
  54. }