| 1 |
<?php |
| 2 |
|
| 3 |
// Start of session v. |
| 4 |
|
| 5 |
interface SessionHandlerInterface { |
| 6 |
|
| 7 |
/** |
| 8 |
* Initialize session |
| 9 |
* @link http://www.php.net/manual/en/sessionhandlerinterface.open.php |
| 10 |
* @param save_path string <p> |
| 11 |
* The path where to store/retrieve the session. |
| 12 |
* </p> |
| 13 |
* @param name string <p> |
| 14 |
* The session name. |
| 15 |
* </p> |
| 16 |
* @return bool &returns.session.storage.retval; |
| 17 |
*/ |
| 18 |
abstract public function open ($save_path, $name) ; |
| 19 |
|
| 20 |
/** |
| 21 |
* Close the session |
| 22 |
* @link http://www.php.net/manual/en/sessionhandlerinterface.close.php |
| 23 |
* @return bool &returns.session.storage.retval; |
| 24 |
*/ |
| 25 |
abstract public function close () ; |
| 26 |
|
| 27 |
/** |
| 28 |
* Read session data |
| 29 |
* @link http://www.php.net/manual/en/sessionhandlerinterface.read.php |
| 30 |
* @param session_id string <p> |
| 31 |
* The session id. |
| 32 |
* </p> |
| 33 |
* @return string an encoded string of the read data. If nothing was read, it must return an empty string. Note this value is returned internally to PHP for processing. |
| 34 |
*/ |
| 35 |
abstract public function read ($session_id) ; |
| 36 |
|
| 37 |
/** |
| 38 |
* Write session data |
| 39 |
* @link http://www.php.net/manual/en/sessionhandlerinterface.write.php |
| 40 |
* @param session_id string <p> |
| 41 |
* The session id. |
| 42 |
* </p> |
| 43 |
* @param session_data string <p> |
| 44 |
* The encoded session data. This data is the result of the PHP internally encoding the $_SESSION superglobal to a serialized |
| 45 |
* string and passing it as this parameter. Please note sessions use an alternative serialization method. |
| 46 |
* </p> |
| 47 |
* @return bool &returns.session.storage.retval; |
| 48 |
*/ |
| 49 |
abstract public function write ($session_id, $session_data) ; |
| 50 |
|
| 51 |
/** |
| 52 |
* Destroy a session |
| 53 |
* @link http://www.php.net/manual/en/sessionhandlerinterface.destroy.php |
| 54 |
* @param session_id string <p> |
| 55 |
* The session ID being destroyed. |
| 56 |
* </p> |
| 57 |
* @return bool &returns.session.storage.retval; |
| 58 |
*/ |
| 59 |
abstract public function destroy ($session_id) ; |
| 60 |
|
| 61 |
/** |
| 62 |
* Cleanup old sessions |
| 63 |
* @link http://www.php.net/manual/en/sessionhandlerinterface.gc.php |
| 64 |
* @param maxlifetime string <p> |
| 65 |
* Sessions that have not updated for the last maxlifetime seconds will be removed. |
| 66 |
* </p> |
| 67 |
* @return bool &returns.session.storage.retval; |
| 68 |
*/ |
| 69 |
abstract public function gc ($maxlifetime) ; |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
interface SessionIdInterface { |
| 74 |
|
| 75 |
abstract public function create_sid () ; |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
class SessionHandler implements SessionHandlerInterface, SessionIdInterface { |
| 80 |
|
| 81 |
/** |
| 82 |
* Initialize session |
| 83 |
* @link http://www.php.net/manual/en/sessionhandler.open.php |
| 84 |
* @param save_path string <p> |
| 85 |
* The path where to store/retrieve the session. |
| 86 |
* </p> |
| 87 |
* @param session_id string <p> |
| 88 |
* The session id. |
| 89 |
* </p> |
| 90 |
* @return bool &returns.session.storage.retval; |
| 91 |
*/ |
| 92 |
public function open ($save_path, $session_id) {} |
| 93 |
|
| 94 |
/** |
| 95 |
* Close the session |
| 96 |
* @link http://www.php.net/manual/en/sessionhandler.close.php |
| 97 |
* @return bool &returns.session.storage.retval; |
| 98 |
*/ |
| 99 |
public function close () {} |
| 100 |
|
| 101 |
/** |
| 102 |
* Read session data |
| 103 |
* @link http://www.php.net/manual/en/sessionhandler.read.php |
| 104 |
* @param session_id string <p> |
| 105 |
* The session id to read data for. |
| 106 |
* </p> |
| 107 |
* @return string an encoded string of the read data. If nothing was read, it must return an empty string. Note this value is returned internally to PHP for processing. |
| 108 |
*/ |
| 109 |
public function read ($session_id) {} |
| 110 |
|
| 111 |
/** |
| 112 |
* Write session data |
| 113 |
* @link http://www.php.net/manual/en/sessionhandler.write.php |
| 114 |
* @param session_id string <p> |
| 115 |
* The session id. |
| 116 |
* </p> |
| 117 |
* @param session_data string <p> |
| 118 |
* The encoded session data. This data is the result of the PHP internally encoding the $_SESSION superglobal to a serialized |
| 119 |
* string and passing it as this parameter. Please note sessions use an alternative serialization method. |
| 120 |
* </p> |
| 121 |
* @return bool &returns.session.storage.retval; |
| 122 |
*/ |
| 123 |
public function write ($session_id, $session_data) {} |
| 124 |
|
| 125 |
/** |
| 126 |
* Destroy a session |
| 127 |
* @link http://www.php.net/manual/en/sessionhandler.destroy.php |
| 128 |
* @param session_id string <p> |
| 129 |
* The session ID being destroyed. |
| 130 |
* </p> |
| 131 |
* @return bool &returns.session.storage.retval; |
| 132 |
*/ |
| 133 |
public function destroy ($session_id) {} |
| 134 |
|
| 135 |
/** |
| 136 |
* Cleanup old sessions |
| 137 |
* @link http://www.php.net/manual/en/sessionhandler.gc.php |
| 138 |
* @param maxlifetime int <p> |
| 139 |
* Sessions that have not updated for the last maxlifetime seconds will be removed. |
| 140 |
* </p> |
| 141 |
* @return bool &returns.session.storage.retval; |
| 142 |
*/ |
| 143 |
public function gc ($maxlifetime) {} |
| 144 |
|
| 145 |
/** |
| 146 |
* Return a new session ID |
| 147 |
* @link http://www.php.net/manual/en/sessionhandler.create-sid.php |
| 148 |
* @return string A session ID valid for the default session handler. |
| 149 |
*/ |
| 150 |
public function create_sid () {} |
| 151 |
|
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Get and/or set the current session name |
| 156 |
* @link http://www.php.net/manual/en/function.session-name.php |
| 157 |
* @param name string[optional] <p> |
| 158 |
* The session name references the name of the session, which is |
| 159 |
* used in cookies and URLs (e.g. PHPSESSID). It |
| 160 |
* should contain only alphanumeric characters; it should be short and |
| 161 |
* descriptive (i.e. for users with enabled cookie warnings). |
| 162 |
* If name is specified, the name of the current |
| 163 |
* session is changed to its value. |
| 164 |
* </p> |
| 165 |
* <p> |
| 166 |
* |
| 167 |
* <p> |
| 168 |
* The session name can't consist of digits only, at least one letter |
| 169 |
* must be present. Otherwise a new session id is generated every time. |
| 170 |
* </p> |
| 171 |
* |
| 172 |
* </p> |
| 173 |
* @return string the name of the current session. |
| 174 |
*/ |
| 175 |
function session_name ($name = null) {} |
| 176 |
|
| 177 |
/** |
| 178 |
* Get and/or set the current session module |
| 179 |
* @link http://www.php.net/manual/en/function.session-module-name.php |
| 180 |
* @param module string[optional] <p> |
| 181 |
* If module is specified, that module will be |
| 182 |
* used instead. |
| 183 |
* </p> |
| 184 |
* @return string the name of the current session module. |
| 185 |
*/ |
| 186 |
function session_module_name ($module = null) {} |
| 187 |
|
| 188 |
/** |
| 189 |
* Get and/or set the current session save path |
| 190 |
* @link http://www.php.net/manual/en/function.session-save-path.php |
| 191 |
* @param path string[optional] <p> |
| 192 |
* Session data path. If specified, the path to which data is saved will |
| 193 |
* be changed. session_save_path needs to be called |
| 194 |
* before session_start for that purpose. |
| 195 |
* </p> |
| 196 |
* <p> |
| 197 |
* |
| 198 |
* <p> |
| 199 |
* On some operating systems, you may want to specify a path on a |
| 200 |
* filesystem that handles lots of small files efficiently. For example, |
| 201 |
* on Linux, reiserfs may provide better performance than ext2fs. |
| 202 |
* </p> |
| 203 |
* |
| 204 |
* </p> |
| 205 |
* @return string the path of the current directory used for data storage. |
| 206 |
*/ |
| 207 |
function session_save_path ($path = null) {} |
| 208 |
|
| 209 |
/** |
| 210 |
* Get and/or set the current session id |
| 211 |
* @link http://www.php.net/manual/en/function.session-id.php |
| 212 |
* @param id string[optional] <p> |
| 213 |
* If id is specified, it will replace the current |
| 214 |
* session id. session_id needs to be called before |
| 215 |
* session_start for that purpose. Depending on the |
| 216 |
* session handler, not all characters are allowed within the session id. |
| 217 |
* For example, the file session handler only allows characters in the |
| 218 |
* range a-z A-Z 0-9 , (comma) and - (minus)! |
| 219 |
* </p> |
| 220 |
* |
| 221 |
* |
| 222 |
* When using session cookies, specifying an id |
| 223 |
* for session_id will always send a new cookie |
| 224 |
* when session_start is called, regardless if the |
| 225 |
* current session id is identical to the one being set. |
| 226 |
* @return string session_id returns the session id for the current |
| 227 |
* session or the empty string ("") if there is no current |
| 228 |
* session (no current session id exists). |
| 229 |
*/ |
| 230 |
function session_id ($id = null) {} |
| 231 |
|
| 232 |
/** |
| 233 |
* Update the current session id with a newly generated one |
| 234 |
* @link http://www.php.net/manual/en/function.session-regenerate-id.php |
| 235 |
* @param delete_old_session bool[optional] <p> |
| 236 |
* Whether to delete the old associated session file or not. |
| 237 |
* </p> |
| 238 |
* @return bool Returns true on success, false on failure. |
| 239 |
*/ |
| 240 |
function session_regenerate_id ($delete_old_session = null) {} |
| 241 |
|
| 242 |
/** |
| 243 |
* Decodes session data from a session encoded string |
| 244 |
* @link http://www.php.net/manual/en/function.session-decode.php |
| 245 |
* @param data string <p> |
| 246 |
* The encoded data to be stored. |
| 247 |
* </p> |
| 248 |
* @return bool Returns true on success, false on failure. |
| 249 |
*/ |
| 250 |
function session_decode ($data) {} |
| 251 |
|
| 252 |
/** |
| 253 |
* Encodes the current session data as a session encoded string |
| 254 |
* @link http://www.php.net/manual/en/function.session-encode.php |
| 255 |
* @return string the contents of the current session encoded. |
| 256 |
*/ |
| 257 |
function session_encode () {} |
| 258 |
|
| 259 |
/** |
| 260 |
* Start new or resume existing session |
| 261 |
* @link http://www.php.net/manual/en/function.session-start.php |
| 262 |
* @return bool This function returns true if a session was successfully started, |
| 263 |
* otherwise false. |
| 264 |
*/ |
| 265 |
function session_start () {} |
| 266 |
|
| 267 |
/** |
| 268 |
* Destroys all data registered to a session |
| 269 |
* @link http://www.php.net/manual/en/function.session-destroy.php |
| 270 |
* @return bool Returns true on success, false on failure. |
| 271 |
*/ |
| 272 |
function session_destroy () {} |
| 273 |
|
| 274 |
/** |
| 275 |
* Free all session variables |
| 276 |
* @link http://www.php.net/manual/en/function.session-unset.php |
| 277 |
* @return void |
| 278 |
*/ |
| 279 |
function session_unset () {} |
| 280 |
|
| 281 |
/** |
| 282 |
* Sets user-level session storage functions |
| 283 |
* @link http://www.php.net/manual/en/function.session-set-save-handler.php |
| 284 |
* @param open callable |
| 285 |
* @param close callable |
| 286 |
* @param read callable |
| 287 |
* @param write callable |
| 288 |
* @param destroy callable |
| 289 |
* @param gc callable |
| 290 |
* @param create_sid callable[optional] |
| 291 |
* @return bool Returns true on success, false on failure. |
| 292 |
*/ |
| 293 |
function session_set_save_handler ($open, $close, $read, $write, $destroy, $gc, $create_sid = null) {} |
| 294 |
|
| 295 |
/** |
| 296 |
* Get and/or set the current cache limiter |
| 297 |
* @link http://www.php.net/manual/en/function.session-cache-limiter.php |
| 298 |
* @param cache_limiter string[optional] <p> |
| 299 |
* If cache_limiter is specified, the name of the |
| 300 |
* current cache limiter is changed to the new value. |
| 301 |
* </p> |
| 302 |
* <table> |
| 303 |
* Possible values |
| 304 |
* |
| 305 |
* |
| 306 |
* <tr valign="top"> |
| 307 |
* <td>Value</td> |
| 308 |
* <td>Headers sent</td> |
| 309 |
* </tr> |
| 310 |
* |
| 311 |
* |
| 312 |
* <tr valign="top"> |
| 313 |
* <td>public</td> |
| 314 |
* <td> |
| 315 |
* |
| 316 |
* |
| 317 |
* </td> |
| 318 |
* </tr> |
| 319 |
* <tr valign="top"> |
| 320 |
* <td>private_no_expire</td> |
| 321 |
* <td> |
| 322 |
* |
| 323 |
* |
| 324 |
* </td> |
| 325 |
* </tr> |
| 326 |
* <tr valign="top"> |
| 327 |
* <td>private</td> |
| 328 |
* <td> |
| 329 |
* |
| 330 |
* |
| 331 |
* </td> |
| 332 |
* </tr> |
| 333 |
* <tr valign="top"> |
| 334 |
* <td>nocache</td> |
| 335 |
* <td> |
| 336 |
* |
| 337 |
* |
| 338 |
* </td> |
| 339 |
* </tr> |
| 340 |
* |
| 341 |
* |
| 342 |
* </table> |
| 343 |
* @return string the name of the current cache limiter. |
| 344 |
*/ |
| 345 |
function session_cache_limiter ($cache_limiter = null) {} |
| 346 |
|
| 347 |
/** |
| 348 |
* Return current cache expire |
| 349 |
* @link http://www.php.net/manual/en/function.session-cache-expire.php |
| 350 |
* @param new_cache_expire string[optional] <p> |
| 351 |
* If new_cache_expire is given, the current cache |
| 352 |
* expire is replaced with new_cache_expire. |
| 353 |
* </p> |
| 354 |
* <p> |
| 355 |
* |
| 356 |
* |
| 357 |
* Setting new_cache_expire is of value only, if |
| 358 |
* session.cache_limiter is set to a value |
| 359 |
* different from nocache. |
| 360 |
* |
| 361 |
* |
| 362 |
* </p> |
| 363 |
* @return int the current setting of session.cache_expire. |
| 364 |
* The value returned should be read in minutes, defaults to 180. |
| 365 |
*/ |
| 366 |
function session_cache_expire ($new_cache_expire = null) {} |
| 367 |
|
| 368 |
/** |
| 369 |
* Set the session cookie parameters |
| 370 |
* @link http://www.php.net/manual/en/function.session-set-cookie-params.php |
| 371 |
* @param lifetime int <p> |
| 372 |
* Lifetime of the |
| 373 |
* session cookie, defined in seconds. |
| 374 |
* </p> |
| 375 |
* @param path string[optional] <p> |
| 376 |
* Path on the domain where |
| 377 |
* the cookie will work. Use a single slash ('/') for all paths on the |
| 378 |
* domain. |
| 379 |
* </p> |
| 380 |
* @param domain string[optional] <p> |
| 381 |
* Cookie domain, for |
| 382 |
* example 'www.php.net'. To make cookies visible on all subdomains then |
| 383 |
* the domain must be prefixed with a dot like '.php.net'. |
| 384 |
* </p> |
| 385 |
* @param secure bool[optional] <p> |
| 386 |
* If true cookie will only be sent over |
| 387 |
* secure connections. |
| 388 |
* </p> |
| 389 |
* @param httponly bool[optional] <p> |
| 390 |
* If set to true then PHP will attempt to send the |
| 391 |
* httponly |
| 392 |
* flag when setting the session cookie. |
| 393 |
* </p> |
| 394 |
* @return void |
| 395 |
*/ |
| 396 |
function session_set_cookie_params ($lifetime, $path = null, $domain = null, $secure = null, $httponly = null) {} |
| 397 |
|
| 398 |
/** |
| 399 |
* Get the session cookie parameters |
| 400 |
* @link http://www.php.net/manual/en/function.session-get-cookie-params.php |
| 401 |
* @return array an array with the current session cookie information, the array |
| 402 |
* contains the following items: |
| 403 |
* |
| 404 |
* |
| 405 |
* |
| 406 |
* "lifetime" - The |
| 407 |
* lifetime of the cookie in seconds. |
| 408 |
* |
| 409 |
* |
| 410 |
* |
| 411 |
* |
| 412 |
* "path" - The path where |
| 413 |
* information is stored. |
| 414 |
* |
| 415 |
* |
| 416 |
* |
| 417 |
* |
| 418 |
* "domain" - The domain |
| 419 |
* of the cookie. |
| 420 |
* |
| 421 |
* |
| 422 |
* |
| 423 |
* |
| 424 |
* "secure" - The cookie |
| 425 |
* should only be sent over secure connections. |
| 426 |
* |
| 427 |
* |
| 428 |
* |
| 429 |
* |
| 430 |
* "httponly" - The |
| 431 |
* cookie can only be accessed through the HTTP protocol. |
| 432 |
*/ |
| 433 |
function session_get_cookie_params () {} |
| 434 |
|
| 435 |
/** |
| 436 |
* Write session data and end session |
| 437 |
* @link http://www.php.net/manual/en/function.session-write-close.php |
| 438 |
* @return void |
| 439 |
*/ |
| 440 |
function session_write_close () {} |
| 441 |
|
| 442 |
/** |
| 443 |
* Discard session array changes and finish session |
| 444 |
* @link http://www.php.net/manual/en/function.session-abort.php |
| 445 |
* @return bool This function returns true if a session was successfully reinitialized, |
| 446 |
* otherwise false. |
| 447 |
*/ |
| 448 |
function session_abort () {} |
| 449 |
|
| 450 |
/** |
| 451 |
* Re-initialize session array with original values |
| 452 |
* @link http://www.php.net/manual/en/function.session-reset.php |
| 453 |
* @return bool This function returns true if a session was successfully reinitialized, |
| 454 |
* otherwise false. |
| 455 |
*/ |
| 456 |
function session_reset () {} |
| 457 |
|
| 458 |
/** |
| 459 |
* Returns the current session status |
| 460 |
* @link http://www.php.net/manual/en/function.session-status.php |
| 461 |
*/ |
| 462 |
function session_status () {} |
| 463 |
|
| 464 |
/** |
| 465 |
* Session shutdown function |
| 466 |
* @link http://www.php.net/manual/en/function.session-register-shutdown.php |
| 467 |
* @return void |
| 468 |
*/ |
| 469 |
function session_register_shutdown () {} |
| 470 |
|
| 471 |
/** |
| 472 |
* &Alias; <function>session_write_close</function> |
| 473 |
* @link http://www.php.net/manual/en/function.session-commit.php |
| 474 |
*/ |
| 475 |
function session_commit () {} |
| 476 |
|
| 477 |
|
| 478 |
/** |
| 479 |
* Since PHP 5.4.0. Return value of session_status if sessions are disabled. |
| 480 |
* @link http://www.php.net/manual/en/session.constants.php |
| 481 |
*/ |
| 482 |
define ('PHP_SESSION_DISABLED', 0); |
| 483 |
|
| 484 |
/** |
| 485 |
* Since PHP 5.4.0. Return value of session_status if sessions are enabled, |
| 486 |
* but no session exists. |
| 487 |
* @link http://www.php.net/manual/en/session.constants.php |
| 488 |
*/ |
| 489 |
define ('PHP_SESSION_NONE', 1); |
| 490 |
|
| 491 |
/** |
| 492 |
* Since PHP 5.4.0. Return value of session_status if sessions are enabled, |
| 493 |
* and a session exists. |
| 494 |
* @link http://www.php.net/manual/en/session.constants.php |
| 495 |
*/ |
| 496 |
define ('PHP_SESSION_ACTIVE', 2); |
| 497 |
|
| 498 |
// End of session v. |
| 499 |
?> |