Source for file Session.php
Documentation is available at Session.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- 7: *
- 8: * This source file is subject to the "Nette license" that is bundled
- 9: * with this package in the file license.txt.
- 10: *
- 11: * For more information please see https://nette.org
- 12: *
- 19: */
- 27: /**
- 28: * Provides access to session namespaces as well as session settings and management methods.
- 29: *
- 33: */
- 35: {
- 36: /** Default file lifetime is 3 hours */
- 50: // security
- 56: // cookies
- 63: // other
- 74: {
- 76: }
- 80: /**
- 81: * Starts and initializes session data.
- 84: */
- 86: {
- 91: throw new InvalidStateException('A session had already been started by session.auto-start or session_start().');
- 92: }
- 95: // additional protection against Session Hijacking & Fixation
- 100: throw new InvalidStateException("Verification key generator '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
- 101: }
- 102: }
- 105: // start session
- 113: }
- 119: }
- 121: /* structure:
- 122: nette: __NT
- 123: data: __NS->namespace->variable = data
- 124: meta: __NM->namespace->EXP->variable = timestamp
- 125: */
- 127: // initialize structures
- 128: $verKey = $this->verificationKeyGenerator ? (string) call_user_func($this->verificationKeyGenerator) : '';
- 144: }
- 145: }
- 147: // browser closing detection
- 151: }
- 155: // resend cookie
- 158: // process meta metadata
- 162: // expire namespace variables
- 170: }
- 173: }
- 174: }
- 175: }
- 176: }
- 177: }
- 180: }
- 184: /**
- 185: * Has been session started?
- 187: */
- 189: {
- 191: }
- 195: /**
- 196: * Ends the current session and store session data.
- 198: */
- 200: {
- 204: }
- 205: }
- 209: /**
- 210: * Destroys all data registered to a session.
- 212: */
- 214: {
- 217: }
- 224: $this->getHttpResponse()->deleteCookie(session_name(), $params['path'], $params['domain'], $params['secure']);
- 225: }
- 226: }
- 230: /**
- 231: * Does session exists for the current request?
- 233: */
- 235: {
- 237: }
- 241: /**
- 242: * Regenerates the session ID.
- 245: */
- 247: {
- 250: throw new InvalidStateException("Cannot regenerate session ID after HTTP headers have been sent" . ($file ? " (output started at $file:$line)." : "."));
- 251: }
- 252: $_SESSION['__NT']['V'] = $this->verificationKeyGenerator ? (string) call_user_func($this->verificationKeyGenerator) : '';
- 257: }
- 258: }
- 262: /**
- 263: * Sets the session ID to a specified one.
- 265: */
- 267: {
- 269: }
- 273: /**
- 274: * Returns the current session ID. Don't make dependencies, can be changed for each request.
- 276: */
- 278: {
- 280: }
- 284: /**
- 285: * Sets the session name to a specified one.
- 288: */
- 290: {
- 293: }
- 298: }
- 302: /**
- 303: * Gets the session name.
- 305: */
- 307: {
- 309: }
- 313: /**
- 314: * Generates key as protection against Session Hijacking & Fixation.
- 316: */
- 318: {
- 324: }
- 326: }
- 330: /********************* namespaces management ****************d*g**/
- 334: /**
- 335: * Returns specified session namespace.
- 340: */
- 342: {
- 345: }
- 349: }
- 352: }
- 356: /**
- 357: * Checks if a session namespace exist and is not empty.
- 360: */
- 362: {
- 365: }
- 368: }
- 372: /**
- 373: * Iteration over all namespaces.
- 375: */
- 377: {
- 380: }
- 387: }
- 388: }
- 392: /**
- 393: * Cleans and minimizes meta structures.
- 395: */
- 397: {
- 400: }
- 406: }
- 410: }
- 411: }
- 412: }
- 416: }
- 420: }
- 423: //$this->destroy(); only when shutting down
- 424: }
- 425: }
- 429: /********************* configuration ****************d*g**/
- 433: /**
- 434: * Configurates session environment.
- 440: */
- 442: {
- 455: }
- 462: }
- 468: }
- 473: }
- 475: }
- 476: }
- 479: session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 482: }
- 483: }
- 484: }
- 488: /**
- 489: * Sets the amount of time allowed between requests before the session will be terminated.
- 492: */
- 494: {
- 504: }
- 509: }
- 510: }
- 514: /**
- 515: * Sets the session cookie parameters.
- 520: */
- 522: {
- 528: }
- 532: /**
- 533: * Returns the session cookie parameters.
- 535: */
- 537: {
- 539: }
- 543: /**
- 544: * Sets path of the directory used to save session data.
- 546: */
- 548: {
- 552: }
- 556: /**
- 557: * Sends the session cookies.
- 559: */
- 561: {
- 563: $this->getHttpResponse()->setCookie(session_name(), session_id(), $cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 564: $this->getHttpResponse()->setCookie('nette-browser', $_SESSION['__NT']['B'], HttpResponse::BROWSER, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 565: }
- 569: /********************* backend ****************d*g**/
- 573: /**
- 575: */
- 577: {
- 579: }
- 583: /**
- 585: */
- 587: {
- 589: }
- 591: }