PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.0.7
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.0.7
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / libs / Zend / Session.php
matomo / app / libs / Zend Last commit date
Db 2 years ago Session 2 years ago Config.php 2 years ago Db.php 2 years ago Exception.php 2 years ago LICENSE.txt 6 years ago Registry.php 2 years ago Session.php 2 years ago Version.php 2 years ago
Session.php
765 lines
1 <?php
2
3 namespace {
4 /**
5 * Zend Framework
6 *
7 * LICENSE
8 *
9 * This source file is subject to the new BSD license that is bundled
10 * with this package in the file LICENSE.txt.
11 * It is also available through the world-wide-web at this URL:
12 * http://framework.zend.com/license/new-bsd
13 * If you did not receive a copy of the license and are unable to
14 * obtain it through the world-wide-web, please send an email
15 * to license@zend.com so we can send you a copy immediately.
16 *
17 * @category Zend
18 * @package Zend_Session
19 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: Session.php 24196 2011-07-05 15:58:11Z matthew $
22 * @since Preview Release 0.2
23 */
24 /**
25 * @see Zend_Session_Abstract
26 */
27 // require_once 'Zend/Session/Abstract.php';
28 /**
29 * @see Zend_Session_Namespace
30 */
31 // require_once 'Zend/Session/Namespace.php';
32 /**
33 * @see Zend_Session_SaveHandler_Interface
34 */
35 // require_once 'Zend/Session/SaveHandler/Interface.php';
36 /**
37 * Zend_Session
38 *
39 * @category Zend
40 * @package Zend_Session
41 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
42 * @license http://framework.zend.com/license/new-bsd New BSD License
43 */
44 class Zend_Session extends \Zend_Session_Abstract
45 {
46 /**
47 * Whether or not Zend_Session is being used with unit tests
48 *
49 * @internal
50 * @var bool
51 */
52 public static $_unitTestEnabled = \false;
53 /**
54 * $_throwStartupException
55 *
56 * @var bool|bitset This could also be a combiniation of error codes to catch
57 */
58 protected static $_throwStartupExceptions = \true;
59 /**
60 * Check whether or not the session was started
61 *
62 * @var bool
63 */
64 private static $_sessionStarted = \false;
65 /**
66 * Whether or not the session id has been regenerated this request.
67 *
68 * Id regeneration state
69 * <0 - regenerate requested when session is started
70 * 0 - do nothing
71 * >0 - already called session_regenerate_id()
72 *
73 * @var int
74 */
75 private static $_regenerateIdState = 0;
76 /**
77 * Private list of php's ini values for ext/session
78 * null values will default to the php.ini value, otherwise
79 * the value below will overwrite the default ini value, unless
80 * the user has set an option explicity with setOptions()
81 *
82 * @var array
83 */
84 private static $_defaultOptions = array(
85 'save_path' => null,
86 'name' => null,
87 /* this should be set to a unique value for each application */
88 'save_handler' => null,
89 //'auto_start' => null, /* intentionally excluded (see manual) */
90 'gc_probability' => null,
91 'gc_divisor' => null,
92 'gc_maxlifetime' => null,
93 'serialize_handler' => null,
94 'cookie_lifetime' => null,
95 'cookie_path' => null,
96 'cookie_domain' => null,
97 'cookie_secure' => null,
98 'cookie_httponly' => null,
99 'use_cookies' => null,
100 'use_only_cookies' => 'on',
101 'referer_check' => null,
102 'entropy_file' => null,
103 'entropy_length' => null,
104 'cache_limiter' => null,
105 'cache_expire' => null,
106 'use_trans_sid' => null,
107 'bug_compat_42' => null,
108 'bug_compat_warn' => null,
109 'hash_function' => null,
110 'hash_bits_per_character' => null,
111 );
112 /**
113 * List of options pertaining to Zend_Session that can be set by developers
114 * using Zend_Session::setOptions(). This list intentionally duplicates
115 * the individual declaration of static "class" variables by the same names.
116 *
117 * @var array
118 */
119 private static $_localOptions = array('strict' => '_strict', 'remember_me_seconds' => '_rememberMeSeconds', 'throw_startup_exceptions' => '_throwStartupExceptions');
120 /**
121 * Whether or not write close has been performed.
122 *
123 * @var bool
124 */
125 private static $_writeClosed = \false;
126 /**
127 * Whether or not session id cookie has been deleted
128 *
129 * @var bool
130 */
131 private static $_sessionCookieDeleted = \false;
132 /**
133 * Whether or not session has been destroyed via session_destroy()
134 *
135 * @var bool
136 */
137 private static $_destroyed = \false;
138 /**
139 * Whether or not session must be initiated before usage
140 *
141 * @var bool
142 */
143 private static $_strict = \false;
144 /**
145 * Default number of seconds the session will be remembered for when asked to be remembered
146 *
147 * @var int
148 */
149 private static $_rememberMeSeconds = 1209600;
150 // 2 weeks
151 /**
152 * Whether the default options listed in Zend_Session::$_localOptions have been set
153 *
154 * @var bool
155 */
156 private static $_defaultOptionsSet = \false;
157 /**
158 * A reference to the set session save handler
159 *
160 * @var Zend_Session_SaveHandler_Interface
161 */
162 private static $_saveHandler = null;
163 /**
164 * Constructor overriding - make sure that a developer cannot instantiate
165 */
166 protected function __construct()
167 {
168 }
169 /**
170 * setOptions - set both the class specified
171 *
172 * @param array $userOptions - pass-by-keyword style array of <option name, option value> pairs
173 * @throws Zend_Session_Exception
174 * @return void
175 */
176 public static function setOptions(array $userOptions = array())
177 {
178 // set default options on first run only (before applying user settings)
179 if (!self::$_defaultOptionsSet) {
180 foreach (self::$_defaultOptions as $defaultOptionName => $defaultOptionValue) {
181 if (isset(self::$_defaultOptions[$defaultOptionName])) {
182 @\ini_set("session.{$defaultOptionName}", $defaultOptionValue);
183 }
184 }
185 self::$_defaultOptionsSet = \true;
186 }
187 // set the options the user has requested to set
188 foreach ($userOptions as $userOptionName => $userOptionValue) {
189 $userOptionName = \strtolower($userOptionName);
190 // set the ini based values
191 if (\array_key_exists($userOptionName, self::$_defaultOptions)) {
192 @\ini_set("session.{$userOptionName}", $userOptionValue);
193 } elseif (isset(self::$_localOptions[$userOptionName])) {
194 self::${self::$_localOptions[$userOptionName]} = $userOptionValue;
195 } else {
196 /** @see Zend_Session_Exception */
197 // require_once 'Zend/Session/Exception.php';
198 throw new \Zend_Session_Exception("Unknown option: {$userOptionName} = {$userOptionValue}");
199 }
200 }
201 }
202 /**
203 * getOptions()
204 *
205 * @param string $optionName OPTIONAL
206 * @return array|string
207 */
208 public static function getOptions($optionName = null)
209 {
210 $options = array();
211 foreach (\ini_get_all('session') as $sysOptionName => $sysOptionValues) {
212 $options[\substr($sysOptionName, 8)] = $sysOptionValues['local_value'];
213 }
214 foreach (self::$_localOptions as $localOptionName => $localOptionMemberName) {
215 $options[$localOptionName] = self::${$localOptionMemberName};
216 }
217 if ($optionName) {
218 if (\array_key_exists($optionName, $options)) {
219 return $options[$optionName];
220 }
221 return null;
222 }
223 return $options;
224 }
225 /**
226 * setSaveHandler() - Session Save Handler assignment
227 *
228 * @param Zend_Session_SaveHandler_Interface $interface
229 * @return void
230 */
231 public static function setSaveHandler(\Zend_Session_SaveHandler_Interface $saveHandler)
232 {
233 self::$_saveHandler = $saveHandler;
234 if (self::$_unitTestEnabled) {
235 return;
236 }
237 \session_set_save_handler(array(&$saveHandler, 'open'), array(&$saveHandler, 'close'), array(&$saveHandler, 'read'), array(&$saveHandler, 'write'), array(&$saveHandler, 'destroy'), array(&$saveHandler, 'gc'));
238 }
239 /**
240 * getSaveHandler() - Get the session Save Handler
241 *
242 * @return Zend_Session_SaveHandler_Interface
243 */
244 public static function getSaveHandler()
245 {
246 return self::$_saveHandler;
247 }
248 /**
249 * regenerateId() - Regenerate the session id. Best practice is to call this after
250 * session is started. If called prior to session starting, session id will be regenerated
251 * at start time.
252 *
253 * @throws Zend_Session_Exception
254 * @return void
255 */
256 public static function regenerateId()
257 {
258 if (!self::$_unitTestEnabled && \headers_sent($filename, $linenum)) {
259 /** @see Zend_Session_Exception */
260 // require_once 'Zend/Session/Exception.php';
261 throw new \Zend_Session_Exception("You must call " . __CLASS__ . '::' . __FUNCTION__ . "() before any output has been sent to the browser; output started in {$filename}/{$linenum}");
262 }
263 if (!self::$_sessionStarted) {
264 self::$_regenerateIdState = -1;
265 } else {
266 if (!self::$_unitTestEnabled) {
267 \session_regenerate_id(\true);
268 self::rewriteSessionCookieWithSameSiteDirective();
269 }
270 self::$_regenerateIdState = 1;
271 }
272 }
273 /**
274 * Check if there is a Set-Cookie header present - if so, overwrite it with
275 * a similar header which also includes a SameSite directive. This workaround
276 * is needed because the SameSite property on the session cookie is not supported
277 * by PHP until 7.3.
278 */
279 private static function rewriteSessionCookieWithSameSiteDirective()
280 {
281 $headers = \headers_list();
282 $cookieHeader = '';
283 foreach ($headers as $header) {
284 if (\strpos($header, 'Set-Cookie: ' . \Piwik\Session::SESSION_NAME) === 0) {
285 $cookieHeader = $header;
286 break;
287 }
288 }
289 if (!$cookieHeader) {
290 return;
291 }
292 if (\stripos($cookieHeader, 'SameSite') === \false) {
293 $cookieHeader .= '; SameSite=' . \Piwik\Session::getSameSiteCookieValue();
294 \header($cookieHeader);
295 }
296 }
297 /**
298 * rememberMe() - Write a persistent cookie that expires after a number of seconds in the future. If no number of
299 * seconds is specified, then this defaults to self::$_rememberMeSeconds. Due to clock errors on end users' systems,
300 * large values are recommended to avoid undesirable expiration of session cookies.
301 *
302 * @param int $seconds OPTIONAL specifies TTL for cookie in seconds from present time
303 * @return void
304 */
305 public static function rememberMe($seconds = null)
306 {
307 $seconds = (int) $seconds;
308 $seconds = $seconds > 0 ? $seconds : self::$_rememberMeSeconds;
309 self::rememberUntil($seconds);
310 }
311 /**
312 * forgetMe() - Write a volatile session cookie, removing any persistent cookie that may have existed. The session
313 * would end upon, for example, termination of a web browser program.
314 *
315 * @return void
316 */
317 public static function forgetMe()
318 {
319 self::rememberUntil(0);
320 }
321 /**
322 * rememberUntil() - This method does the work of changing the state of the session cookie and making
323 * sure that it gets resent to the browser via regenerateId()
324 *
325 * @param int $seconds
326 * @return void
327 */
328 public static function rememberUntil($seconds = 0)
329 {
330 if (self::$_unitTestEnabled) {
331 self::regenerateId();
332 return;
333 }
334 $cookieParams = \session_get_cookie_params();
335 \session_set_cookie_params($seconds, $cookieParams['path'], $cookieParams['domain'], $cookieParams['secure']);
336 // normally "rememberMe()" represents a security context change, so should use new session id
337 self::regenerateId();
338 }
339 /**
340 * sessionExists() - whether or not a session exists for the current request
341 *
342 * @return bool
343 */
344 public static function sessionExists()
345 {
346 if (\ini_get('session.use_cookies') == '1' && isset($_COOKIE[\session_name()])) {
347 return \true;
348 } elseif (!empty($_REQUEST[\session_name()])) {
349 return \true;
350 } elseif (self::$_unitTestEnabled) {
351 return \true;
352 }
353 return \false;
354 }
355 /**
356 * Whether or not session has been destroyed via session_destroy()
357 *
358 * @return bool
359 */
360 public static function isDestroyed()
361 {
362 return self::$_destroyed;
363 }
364 /**
365 * start() - Start the session.
366 *
367 * @param bool|array $options OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
368 * @throws Zend_Session_Exception
369 * @return void
370 */
371 public static function start($options = \false)
372 {
373 if (self::$_sessionStarted && self::$_destroyed) {
374 // require_once 'Zend/Session/Exception.php';
375 throw new \Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
376 }
377 if (self::$_sessionStarted) {
378 return;
379 // already started
380 }
381 if (\session_status() === \PHP_SESSION_ACTIVE) {
382 parent::$_readable = \true;
383 parent::$_writable = \true;
384 self::$_sessionStarted = \true;
385 return;
386 }
387 // make sure our default options (at the least) have been set
388 if (!self::$_defaultOptionsSet) {
389 self::setOptions(\is_array($options) ? $options : array());
390 }
391 // In strict mode, do not allow auto-starting Zend_Session, such as via "new Zend_Session_Namespace()"
392 if (self::$_strict && $options === \true) {
393 /** @see Zend_Session_Exception */
394 // require_once 'Zend/Session/Exception.php';
395 throw new \Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.');
396 }
397 $filename = $linenum = null;
398 if (!self::$_unitTestEnabled && \headers_sent($filename, $linenum)) {
399 /** @see Zend_Session_Exception */
400 // require_once 'Zend/Session/Exception.php';
401 throw new \Zend_Session_Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
402 }
403 /**
404 * Hack to throw exceptions on start instead of php errors
405 * @see http://framework.zend.com/issues/browse/ZF-1325
406 */
407 $errorLevel = \is_int(self::$_throwStartupExceptions) ? self::$_throwStartupExceptions : \E_ALL;
408 /** @see Zend_Session_Exception */
409 if (!self::$_unitTestEnabled) {
410 if (self::$_throwStartupExceptions) {
411 // require_once 'Zend/Session/Exception.php';
412 \set_error_handler(array('Zend_Session_Exception', 'handleSessionStartError'), $errorLevel);
413 }
414 $startedCleanly = \session_start();
415 if (self::$_throwStartupExceptions) {
416 \restore_error_handler();
417 }
418 if (!$startedCleanly || !empty(\Zend_Session_Exception::$sessionStartError)) {
419 if (self::$_throwStartupExceptions) {
420 \set_error_handler(array('Zend_Session_Exception', 'handleSilentWriteClose'), $errorLevel);
421 }
422 \session_write_close();
423 if (self::$_throwStartupExceptions) {
424 \restore_error_handler();
425 throw new \Zend_Session_Exception(__CLASS__ . '::' . __FUNCTION__ . '() - ' . \Zend_Session_Exception::$sessionStartError . ' Warnings: ' . \Zend_Session_Exception::$sessionStartWarning);
426 }
427 }
428 }
429 parent::$_readable = \true;
430 parent::$_writable = \true;
431 self::$_sessionStarted = \true;
432 if (self::$_regenerateIdState === -1) {
433 self::regenerateId();
434 } else {
435 self::rewriteSessionCookieWithSameSiteDirective();
436 }
437 if (isset($_SESSION['data']) && \is_string($_SESSION['data'])) {
438 $_SESSION = \Piwik\Common::safe_unserialize(\base64_decode($_SESSION['data']), [\Piwik\Notification::class]);
439 }
440 // run validators if they exist
441 if (isset($_SESSION['__ZF']['VALID'])) {
442 self::_processValidators();
443 }
444 self::_processStartupMetadataGlobal();
445 }
446 /**
447 * _processGlobalMetadata() - this method initizes the sessions GLOBAL
448 * metadata, mostly global data expiration calculations.
449 *
450 * @return void
451 */
452 private static function _processStartupMetadataGlobal()
453 {
454 // process global metadata
455 if (isset($_SESSION['__ZF'])) {
456 // expire globally expired values
457 foreach ($_SESSION['__ZF'] as $namespace => $namespace_metadata) {
458 // Expire Namespace by Time (ENT)
459 if (isset($namespace_metadata['ENT']) && $namespace_metadata['ENT'] > 0 && \time() > $namespace_metadata['ENT']) {
460 unset($_SESSION[$namespace]);
461 unset($_SESSION['__ZF'][$namespace]);
462 }
463 // Expire Namespace by Global Hop (ENGH) if it wasnt expired above
464 if (isset($_SESSION['__ZF'][$namespace]) && isset($namespace_metadata['ENGH']) && $namespace_metadata['ENGH'] >= 1) {
465 $_SESSION['__ZF'][$namespace]['ENGH']--;
466 if ($_SESSION['__ZF'][$namespace]['ENGH'] === 0) {
467 if (isset($_SESSION[$namespace])) {
468 parent::$_expiringData[$namespace] = $_SESSION[$namespace];
469 unset($_SESSION[$namespace]);
470 }
471 unset($_SESSION['__ZF'][$namespace]);
472 }
473 }
474 // Expire Namespace Variables by Time (ENVT)
475 if (isset($namespace_metadata['ENVT'])) {
476 foreach ($namespace_metadata['ENVT'] as $variable => $time) {
477 if (\time() > $time) {
478 unset($_SESSION[$namespace][$variable]);
479 unset($_SESSION['__ZF'][$namespace]['ENVT'][$variable]);
480 }
481 }
482 if (empty($_SESSION['__ZF'][$namespace]['ENVT'])) {
483 unset($_SESSION['__ZF'][$namespace]['ENVT']);
484 }
485 }
486 // Expire Namespace Variables by Global Hop (ENVGH)
487 if (isset($namespace_metadata['ENVGH'])) {
488 foreach ($namespace_metadata['ENVGH'] as $variable => $hops) {
489 $_SESSION['__ZF'][$namespace]['ENVGH'][$variable]--;
490 if ($_SESSION['__ZF'][$namespace]['ENVGH'][$variable] === 0) {
491 if (isset($_SESSION[$namespace][$variable])) {
492 parent::$_expiringData[$namespace][$variable] = $_SESSION[$namespace][$variable];
493 unset($_SESSION[$namespace][$variable]);
494 }
495 unset($_SESSION['__ZF'][$namespace]['ENVGH'][$variable]);
496 }
497 }
498 if (empty($_SESSION['__ZF'][$namespace]['ENVGH'])) {
499 unset($_SESSION['__ZF'][$namespace]['ENVGH']);
500 }
501 }
502 if (isset($namespace) && empty($_SESSION['__ZF'][$namespace])) {
503 unset($_SESSION['__ZF'][$namespace]);
504 }
505 }
506 }
507 if (isset($_SESSION['__ZF']) && empty($_SESSION['__ZF'])) {
508 unset($_SESSION['__ZF']);
509 }
510 }
511 /**
512 * isStarted() - convenience method to determine if the session is already started.
513 *
514 * @return bool
515 */
516 public static function isStarted()
517 {
518 return self::$_sessionStarted;
519 }
520 /**
521 * isRegenerated() - convenience method to determine if session_regenerate_id()
522 * has been called during this request by Zend_Session.
523 *
524 * @return bool
525 */
526 public static function isRegenerated()
527 {
528 return self::$_regenerateIdState > 0 ? \true : \false;
529 }
530 /**
531 * getId() - get the current session id
532 *
533 * @return string
534 */
535 public static function getId()
536 {
537 return \session_id();
538 }
539 /**
540 * setId() - set an id to a user specified id
541 *
542 * @throws Zend_Session_Exception
543 * @param string $id
544 * @return void
545 */
546 public static function setId($id)
547 {
548 if (!self::$_unitTestEnabled && \defined('SID')) {
549 /** @see Zend_Session_Exception */
550 // require_once 'Zend/Session/Exception.php';
551 throw new \Zend_Session_Exception('The session has already been started. The session id must be set first.');
552 }
553 if (!self::$_unitTestEnabled && \headers_sent($filename, $linenum)) {
554 /** @see Zend_Session_Exception */
555 // require_once 'Zend/Session/Exception.php';
556 throw new \Zend_Session_Exception("You must call " . __CLASS__ . '::' . __FUNCTION__ . "() before any output has been sent to the browser; output started in {$filename}/{$linenum}");
557 }
558 if (!\is_string($id) || $id === '') {
559 /** @see Zend_Session_Exception */
560 // require_once 'Zend/Session/Exception.php';
561 throw new \Zend_Session_Exception('You must provide a non-empty string as a session identifier.');
562 }
563 \session_id($id);
564 }
565 /**
566 * registerValidator() - register a validator that will attempt to validate this session for
567 * every future request
568 *
569 * @param Zend_Session_Validator_Interface $validator
570 * @return void
571 */
572 public static function registerValidator(\Zend_Session_Validator_Interface $validator)
573 {
574 $validator->setup();
575 }
576 /**
577 * stop() - Disable write access. Optionally disable read (not implemented).
578 *
579 * @return void
580 */
581 public static function stop()
582 {
583 parent::$_writable = \false;
584 }
585 /**
586 * writeClose() - Shutdown the sesssion, close writing and detach $_SESSION from the back-end storage mechanism.
587 * This will complete the internal data transformation on this request.
588 *
589 * @param bool $readonly - OPTIONAL remove write access (i.e. throw error if Zend_Session's attempt writes)
590 * @return void
591 */
592 public static function writeClose($readonly = \true)
593 {
594 if (self::$_unitTestEnabled) {
595 return;
596 }
597 if (self::$_writeClosed) {
598 return;
599 }
600 if ($readonly) {
601 parent::$_writable = \false;
602 }
603 if (isset($_SESSION)) {
604 $sessionBkp = $_SESSION;
605 $_SESSION = array('data' => \base64_encode(\serialize($_SESSION)));
606 }
607 \session_write_close();
608 self::$_writeClosed = \true;
609 if (isset($sessionBkp)) {
610 $_SESSION = $sessionBkp;
611 }
612 }
613 /**
614 * destroy() - This is used to destroy session data, and optionally, the session cookie itself
615 *
616 * @param bool $remove_cookie - OPTIONAL remove session id cookie, defaults to true (remove cookie)
617 * @param bool $readonly - OPTIONAL remove write access (i.e. throw error if Zend_Session's attempt writes)
618 * @return void
619 */
620 public static function destroy($remove_cookie = \true, $readonly = \true)
621 {
622 if (self::$_unitTestEnabled) {
623 return;
624 }
625 if (self::$_destroyed) {
626 return;
627 }
628 if ($readonly) {
629 parent::$_writable = \false;
630 }
631 \session_destroy();
632 self::$_destroyed = \true;
633 if ($remove_cookie) {
634 self::expireSessionCookie();
635 }
636 }
637 /**
638 * expireSessionCookie() - Sends an expired session id cookie, causing the client to delete the session cookie
639 *
640 * @return void
641 */
642 public static function expireSessionCookie()
643 {
644 if (self::$_unitTestEnabled) {
645 return;
646 }
647 if (self::$_sessionCookieDeleted) {
648 return;
649 }
650 self::$_sessionCookieDeleted = \true;
651 if (isset($_COOKIE[\session_name()])) {
652 $cookie_params = \session_get_cookie_params();
653 \Piwik\Session::writeCookie(
654 \session_name(),
655 \false,
656 315554400,
657 // strtotime('1980-01-01'),
658 $cookie_params['path'],
659 $cookie_params['domain'],
660 $cookie_params['secure'],
661 \false,
662 \Piwik\Session::getSameSiteCookieValue()
663 );
664 }
665 }
666 /**
667 * _processValidator() - internal function that is called in the existence of VALID metadata
668 *
669 * @throws Zend_Session_Exception
670 * @return void
671 */
672 private static function _processValidators()
673 {
674 foreach ($_SESSION['__ZF']['VALID'] as $validator_name => $valid_data) {
675 if (!\class_exists($validator_name)) {
676 // require_once 'Zend/Loader.php';
677 \Zend_Loader::loadClass($validator_name);
678 }
679 $validator = new $validator_name();
680 if ($validator->validate() === \false) {
681 /** @see Zend_Session_Exception */
682 // require_once 'Zend/Session/Exception.php';
683 throw new \Zend_Session_Exception("This session is not valid according to {$validator_name}.");
684 }
685 }
686 }
687 /**
688 * namespaceIsset() - check to see if a namespace is set
689 *
690 * @param string $namespace
691 * @return bool
692 */
693 public static function namespaceIsset($namespace)
694 {
695 return parent::_namespaceIsset($namespace);
696 }
697 /**
698 * namespaceUnset() - unset a namespace or a variable within a namespace
699 *
700 * @param string $namespace
701 * @throws Zend_Session_Exception
702 * @return void
703 */
704 public static function namespaceUnset($namespace)
705 {
706 parent::_namespaceUnset($namespace);
707 \Zend_Session_Namespace::resetSingleInstance($namespace);
708 }
709 /**
710 * namespaceGet() - get all variables in a namespace
711 * Deprecated: Use getIterator() in Zend_Session_Namespace.
712 *
713 * @param string $namespace
714 * @return array
715 */
716 public static function namespaceGet($namespace)
717 {
718 return parent::_namespaceGetAll($namespace);
719 }
720 /**
721 * getIterator() - return an iteratable object for use in foreach and the like,
722 * this completes the IteratorAggregate interface
723 *
724 * @throws Zend_Session_Exception
725 * @return ArrayObject
726 */
727 public static function getIterator()
728 {
729 if (parent::$_readable === \false) {
730 /** @see Zend_Session_Exception */
731 // require_once 'Zend/Session/Exception.php';
732 throw new \Zend_Session_Exception(parent::_THROW_NOT_READABLE_MSG);
733 }
734 $spaces = array();
735 if (isset($_SESSION)) {
736 $spaces = \array_keys($_SESSION);
737 foreach ($spaces as $key => $space) {
738 if (!\strncmp($space, '__', 2) || !\is_array($_SESSION[$space])) {
739 unset($spaces[$key]);
740 }
741 }
742 }
743 return new \ArrayObject(\array_merge($spaces, \array_keys(parent::$_expiringData)));
744 }
745 /**
746 * isWritable() - returns a boolean indicating if namespaces can write (use setters)
747 *
748 * @return bool
749 */
750 public static function isWritable()
751 {
752 return parent::$_writable;
753 }
754 /**
755 * isReadable() - returns a boolean indicating if namespaces can write (use setters)
756 *
757 * @return bool
758 */
759 public static function isReadable()
760 {
761 return parent::$_readable;
762 }
763 }
764 }
765