public function offsetExists($key) : bool { return is_string($key) && (isset($this->mData[$key]) || isset($this->mData[Crypt::hash($this->mPrefix . $key)])); }
public function __construct(Traversable $data = null) { $this->mData = []; /* * We don't need/want PHP's session system. We do however need the $_SESSION variable, * and we don't need PHP saving it's content where it should not be saved. So we close it * if it is set to autostart. */ if (in_array(strtolower(ini_get("session.auto_start")), ["on", "true", "1"])) { trigger_error("You should disable Session Auto Start while running this library", E_USER_NOTICE); if ($_SESSION == $this) { $_SESSION = []; session_unset(); session_destroy(); $_SESSION = $this; } else { session_unset(); session_destroy(); } /* * This function removes the first header in the list that matches the name. * As session_autostart is executed before anything else, it's session cookie * should be the first in the list. */ header_remove("Set-Cookie"); } /* * Register a receiver used to write data back to session storage */ Runtime::addShutdownReceiver([$this, "writeBack"]); $useSSL = Runtime::$SETTINGS->getBoolean("SECURITY_SSL", false); $isSSL = Runtime::$SYSTEM->getBoolean("CONNECTION_SSL", false); $cookieName = $useSSL && $isSSL ? "IMPHP_SESSID_SSL" : "IMPHP_SESSID"; $cryptKey = null; if (Runtime::$SETTINGS->getBoolean("SESSION_ENCRYPT_COOKIE")) { $cryptKey = Runtime::$SETTINGS->getString("SECURITY_PASSWD"); } try { $this->mSessId = Runtime::$COOKIE->get($cookieName, null, $cryptKey); /* * If anything is wrong, start a new session */ } catch (Exception $e) { } if ($this->mSessId == null) { $this->mSessId = Crypt::hash(Crypt::password() . time()); Runtime::$COOKIE->set($cookieName, $this->mSessId, 0, $useSSL && $isSSL, null, null, $cryptKey); } }