/** * @param string $key the id of the key to get * @return HTML\Form\Security\Key */ static function getKey($key) { if (self::USE_REDIS) { $key = RedisStorage::get($key); if ($key instanceof RedisKey) { if (php_sapi_name() != 'cli') { $session_id = isset($_COOKIE["PHPSESSID"]) ? $_COOKIE["PHPSESSID"] : null; if ($key->session_id !== null && $key->session_id != $session_id) { throw new \Exception("Security Exception, session id does not match"); } } return $key; } else { return; } } else { if (!isset(Session::$data['form_security'])) { throw new \Exception('No security keys in session'); } return Session::$data['form_security'][$key]; } }