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
- 60: /**
- 61: * Starts and initializes session data.
- 64: */
- 66: {
- 71: throw new InvalidStateException('A session had already been started by session.auto-start or session_start().');
- 72: }
- 75: // start session
- 79: // ignore?
- 80: }
- 87: }
- 93: }
- 95: /* structure:
- 96: __NF: Counter, BrowserKey, Data, Meta
- 97: DATA: namespace->variable = data
- 98: META: namespace->variable = Timestamp, Browser, Version
- 99: */
- 103: // initialize structures
- 109: }
- 111: // browser closing detection
- 115: }
- 119: // resend cookie
- 122: // process meta metadata
- 125: // expire namespace variables
- 129: if ((!empty($value['B']) && $browserClosed) || (!empty($value['T']) && $now > $value['T']) // whenBrowserIsClosed || Time
- 131: !== ClassReflection::from($nf['DATA'][$namespace][$variable])->getAnnotation('serializationVersion'))) {
- 136: }
- 138: }
- 139: }
- 140: }
- 141: }
- 142: }
- 145: }
- 149: /**
- 150: * Has been session started?
- 152: */
- 154: {
- 156: }
- 160: /**
- 161: * Ends the current session and store session data.
- 163: */
- 165: {
- 170: }
- 171: }
- 175: /**
- 176: * Destroys all data registered to a session.
- 178: */
- 180: {
- 183: }
- 190: $this->getHttpResponse()->deleteCookie(session_name(), $params['path'], $params['domain'], $params['secure']);
- 191: }
- 192: }
- 196: /**
- 197: * Does session exists for the current request?
- 199: */
- 201: {
- 203: }
- 207: /**
- 208: * Regenerates the session ID.
- 211: */
- 213: {
- 216: throw new InvalidStateException("Cannot regenerate session ID after HTTP headers have been sent" . ($file ? " (output started at $file:$line)." : "."));
- 217: }
- 222: }
- 223: }
- 227: /**
- 228: * Returns the current session ID. Don't make dependencies, can be changed for each request.
- 230: */
- 232: {
- 234: }
- 238: /**
- 239: * Sets the session name to a specified one.
- 242: */
- 244: {
- 247: }
- 253: }
- 257: /**
- 258: * Gets the session name.
- 260: */
- 262: {
- 264: }
- 268: /********************* namespaces management ****************d*g**/
- 272: /**
- 273: * Returns specified session namespace.
- 278: */
- 280: {
- 283: }
- 287: }
- 289: return new $class($_SESSION['__NF']['DATA'][$namespace], $_SESSION['__NF']['META'][$namespace]);
- 290: }
- 294: /**
- 295: * Checks if a session namespace exist and is not empty.
- 298: */
- 300: {
- 303: }
- 306: }
- 310: /**
- 311: * Iteration over all namespaces.
- 313: */
- 315: {
- 318: }
- 325: }
- 326: }
- 330: /**
- 331: * Cleans and minimizes meta structures.
- 333: */
- 335: {
- 338: }
- 345: }
- 346: }
- 347: }
- 351: }
- 355: }
- 358: //$this->destroy(); only when shutting down
- 359: }
- 360: }
- 364: /********************* configuration ****************d*g**/
- 368: /**
- 369: * Sets session options.
- 374: */
- 376: {
- 379: }
- 382: }
- 386: /**
- 387: * Returns all session options.
- 389: */
- 391: {
- 393: }
- 397: /**
- 398: * Configurates session environment.
- 401: */
- 403: {
- 409: }
- 417: }
- 424: }
- 430: }
- 435: }
- 437: }
- 438: }
- 441: session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 444: }
- 445: }
- 446: }
- 450: /**
- 451: * Sets the amount of time allowed between requests before the session will be terminated.
- 454: */
- 456: {
- 469: }
- 470: }
- 474: /**
- 475: * Sets the session cookie parameters.
- 480: */
- 482: {
- 488: }
- 492: /**
- 493: * Returns the session cookie parameters.
- 495: */
- 497: {
- 499: }
- 503: /**
- 504: * Sets path of the directory used to save session data.
- 506: */
- 508: {
- 512: }
- 516: /**
- 517: * Sends the session cookies.
- 519: */
- 521: {
- 523: $this->getHttpResponse()->setCookie(session_name(), session_id(), $cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 524: $this->getHttpResponse()->setCookie('nette-browser', $_SESSION['__NF']['B'], HttpResponse::BROWSER, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- 525: }
- 529: /********************* backend ****************d*g**/
- 533: /**
- 535: */
- 537: {
- 539: }
- 543: /**
- 545: */
- 547: {
- 549: }
- 551: }