Source for file Session.php
Documentation is available at Session.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 11: */
- 15: /**
- 16: * Provides access to session namespaces as well as session settings and management methods.
- 17: *
- 20: */
- 22: {
- 23: /** Default file lifetime is 3 hours */
- 37: // security
- 43: // cookies
- 50: // other
- 61: {
- 63: }
- 67: /**
- 68: * Starts and initializes session data.
- 71: */
- 73: {
- 78: throw new InvalidStateException('A session had already been started by session.auto-start or session_start().');
- 79: }
- 82: // additional protection against Session Hijacking & Fixation
- 86: }
- 88: // start session
- 92: // ignore?
- 93: }
- 100: }
- 106: }
- 108: /* structure:
- 109: __NF: VerificationKey, Counter, BrowserKey, Data, Meta
- 110: DATA: namespace->variable = data
- 111: META: namespace->variable = Timestamp, Browser, Version
- 112: */
- 114: // initialize structures
- 130: }
- 131: }
- 135: // browser closing detection
- 139: }
- 143: // resend cookie
- 146: // process meta metadata
- 149: // expire namespace variables
- 153: if ((!empty($value['B']) && $browserClosed) || (!empty($value['T']) && $now > $value['T']) // whenBrowserIsClosed || Time
- 155: !== ClassReflection::from($nf['DATA'][$namespace][$variable])->getAnnotation('serializationVersion'))) {
- 160: }
- 162: }
- 163: }
- 164: }
- 165: }
- 166: }
- 169: }
- 173: /**
- 174: * Has been session started?
- 176: */
- 178: {
- 180: }
- 184: /**
- 185: * Ends the current session and store session data.
- 187: */
- 189: {
- 194: }
- 195: }
- 199: /**
- 200: * Destroys all data registered to a session.
- 202: */
- 204: {
- 207: }
- 214: $this->getHttpResponse()->deleteCookie(session_name(), $params['path'], $params['domain'], $params['secure']);
- 215: }
- 216: }
- 220: /**
- 221: * Does session exists for the current request?
- 223: */
- 225: {
- 227: }
- 231: /**
- 232: * Regenerates the session ID.
- 235: */
- 237: {
- 240: throw new InvalidStateException("Cannot regenerate session ID after HTTP headers have been sent" . ($file ? " (output started at $file:$line)." : "."));
- 241: }
- 246: }
- 247: }
- 251: /**
- 252: * Returns the current session ID. Don't make dependencies, can be changed for each request.
- 254: */
- 256: {
- 258: }
- 262: /**
- 263: * Sets the session name to a specified one.
- 266: */
- 268: {
- 271: }
- 277: }
- 281: /**
- 282: * Gets the session name.
- 284: */
- 286: {
- 288: }
- 292: /**
- 293: * Generates key as protection against Session Hijacking & Fixation.
- 295: */
- 297: {
- 305: }
- 307: }
- 311: /********************* namespaces management ****************d*g**/
- 315: /**
- 316: * Returns specified session namespace.
- 321: */
- 323: {
- 326: }
- 330: }
- 332: return new $class($_SESSION['__NF']['DATA'][$namespace], $_SESSION['__NF']['META'][$namespace]);
- 333: }
- 337: /**
- 338: * Checks if a session namespace exist and is not empty.
- 341: */
- 343: {
- 346: }
- 349: }
- 353: /**
- 354: * Iteration over all namespaces.
- 356: */
- 358: {
- 361: }
- 368: }
- 369: }
- 373: /**
- 374: * Cleans and minimizes meta structures.
- 376: */
- 378: {
- 381: }
- 388: }
- 389: }
- 390: }
- 394: }
- 398: }
- 401: //$this->destroy(); only when shutting down
- 402: }
- 403: }
- 407: /********************* configuration ****************d*g**/
- 411: /**
- 412: * Sets session options.
- 417: */
- 419: {
- 422: }
- 425: }
- 429: /**
- 430: * Returns all session options.
- 432: */
- 434: {
- 436: }
- 440: /**
- 441: * Configurates session environment.
- 444: */
- 446: {
- 452: }
- 460: }
- 467: }
- 473: }
- 478: }
- 480: }
- 481: }
- 484: session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 487: }
- 488: }
- 489: }
- 493: /**
- 494: * Sets the amount of time allowed between requests before the session will be terminated.
- 497: */
- 499: {
- 512: }
- 513: }
- 517: /**
- 518: * Sets the session cookie parameters.
- 523: */
- 525: {
- 531: }
- 535: /**
- 536: * Returns the session cookie parameters.
- 538: */
- 540: {
- 542: }
- 546: /**
- 547: * Sets path of the directory used to save session data.
- 549: */
- 551: {
- 555: }
- 559: /**
- 560: * Sends the session cookies.
- 562: */
- 564: {
- 566: $this->getHttpResponse()->setCookie(session_name(), session_id(), $cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 567: $this->getHttpResponse()->setCookie('nette-browser', $_SESSION['__NF']['B'], HttpResponse::BROWSER, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 568: }
- 572: /********************* backend ****************d*g**/
- 576: /**
- 578: */
- 580: {
- 582: }
- 586: /**
- 588: */
- 590: {
- 592: }
- 594: }