  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: session.php 1666 2007-07-19 11:55:15Z hpdl $ |
| |
| 3 | + | $Id: session.php 1667 2007-07-19 20:42:39Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
71 | 71 | | */ |
| |
72 | 72 | | |
| |
73 | 73 | | public function __construct($name = null) { |
  |
74 | | - | if ( !osc_empty(basename(STORE_SESSIONS)) && file_exists(dirname(__FILE__) . '/session/' . basename(STORE_SESSIONS) . '.php') ) { |
| |
75 | | - | include(dirname(__FILE__) . '/session/' . basename(STORE_SESSIONS) . '.php'); |
| |
76 | | - | |
| |
77 | | - | $class_name = 'osC_Session_' . basename(STORE_SESSIONS); |
| |
78 | | - | |
| |
79 | | - | return new $class_name($name); |
| |
80 | | - | } |
| |
81 | | - | |
|
82 | 74 | | $this->setName($name); |
| |
83 | 75 | | $this->_setCookieParameters(); |
| |
84 | 76 | | } |
| |
|
|
 |
… |
|
94 | 86 | | } |
| |
95 | 87 | | |
| |
96 | 88 | | /** |
  |
| 89 | + | * Loads the session storage handler |
| |
| 90 | + | * |
| |
| 91 | + | * @param string $name The name of the session |
| |
| 92 | + | * @access public |
| |
| 93 | + | */ |
| |
| 94 | + | |
| |
| 95 | + | public static function load($name = null) { |
| |
| 96 | + | $class_name = 'osC_Session'; |
| |
| 97 | + | |
| |
| 98 | + | if ( !osc_empty(basename(STORE_SESSIONS)) && file_exists(dirname(__FILE__) . '/session/' . basename(STORE_SESSIONS) . '.php') ) { |
| |
| 99 | + | include(dirname(__FILE__) . '/session/' . basename(STORE_SESSIONS) . '.php'); |
| |
| 100 | + | |
| |
| 101 | + | $class_name = 'osC_Session_' . basename(STORE_SESSIONS); |
| |
| 102 | + | } |
| |
| 103 | + | |
| |
| 104 | + | return new $class_name($name); |
| |
| 105 | + | } |
| |
| 106 | + | |
| |
| 107 | + | /** |
|
97 | 108 | | * Verify an existing session ID and create or resume the session if the existing session ID is valid |
| |
98 | 109 | | * |
| |
99 | 110 | | * @access public |
| |
|
|
 |
… |
|
164 | 175 | | setcookie($this->_name, '', time()-42000, $this->getCookieParameters('path'), $this->getCookieParameters('domain')); |
| |
165 | 176 | | } |
| |
166 | 177 | | |
  |
167 | | - | $this->_delete(); |
| |
| 178 | + | $this->delete(); |
|
168 | 179 | | |
| |
169 | 180 | | return session_destroy(); |
| |
170 | 181 | | } |
| |
|
|
 |
… |
|
173 | 184 | | /** |
| |
174 | 185 | | * Deletes an existing session from the storage handler |
| |
175 | 186 | | * |
  |
176 | | - | * @access protected |
| |
| 187 | + | * @param string $id The ID of the session |
| |
| 188 | + | * @access public |
|
177 | 189 | | */ |
| |
178 | 190 | | |
  |
179 | | - | protected function _delete() { |
| |
180 | | - | if ( file_exists($this->_save_path . '/' . $this->_id) ) { |
| |
181 | | - | @unlink($this->_save_path . '/' . $this->_id); |
| |
| 191 | + | public function delete($id = null) { |
| |
| 192 | + | if ( empty($id) ) { |
| |
| 193 | + | $id = $this->_id; |
|
182 | 194 | | } |
  |
| 195 | + | |
| |
| 196 | + | if ( file_exists($this->_save_path . '/' . $id) ) { |
| |
| 197 | + | @unlink($this->_save_path . '/' . $id); |
| |
| 198 | + | } |
  |
183 | 199 | | } |
| |
184 | 200 | | |
| |
185 | 201 | | /** |