rememberMeSeconds; case 'url_rewriter_tags': return ini_get('url_rewriter.tags'); // The following all need a transformation on the retrieved value; // however they use the same key naming scheme case 'use_cookies': case 'use_only_cookies': case 'use_trans_sid': case 'cookie_httponly': return (bool) ini_get('session.' . $storageOption); default: return ini_get('session.' . $storageOption); } } /** * Set session.save_handler * * @param string $phpSaveHandler * @return SessionConfig * @throws Exception\InvalidArgumentException */ public function setPhpSaveHandler($phpSaveHandler) { $phpSaveHandler = (string) $phpSaveHandler; set_error_handler(array($this, 'handleError')); ini_set('session.save_handler', $phpSaveHandler); restore_error_handler(); if ($this->phpErrorCode >= E_WARNING) { throw new Exception\InvalidArgumentException( 'Invalid save handler specified: ' . $this->phpErrorMessage ); } $this->setOption('save_handler', $phpSaveHandler); return $this; } /** * Set session.save_path * * @param string $savePath * @return SessionConfig * @throws Exception\InvalidArgumentException on invalid path */ public function setSavePath($savePath) { if ($this->getOption('save_handler') == 'files') { parent::setSavePath($savePath); } $this->savePath = $savePath; $this->setOption('save_path', $savePath); return $this; } /** * Set session.serialize_handler * * @param string $serializeHandler * @return SessionConfig * @throws Exception\InvalidArgumentException */ public function setSerializeHandler($serializeHandler) { $serializeHandler = (string) $serializeHandler; set_error_handler(array($this, 'handleError')); ini_set('session.serialize_handler', $serializeHandler); restore_error_handler(); if ($this->phpErrorCode >= E_WARNING) { throw new Exception\InvalidArgumentException('Invalid serialize handler specified'); } $this->serializeHandler = (string) $serializeHandler; return $this; } // session.cache_limiter /** * Set cache limiter * * @param $cacheLimiter * @return SessionConfig * @throws Exception\InvalidArgumentException */ public function setCacheLimiter($cacheLimiter) { $cacheLimiter = (string) $cacheLimiter; if (!in_array($cacheLimiter, $this->validCacheLimiters)) { throw new Exception\InvalidArgumentException('Invalid cache limiter provided'); } $this->setOption('cache_limiter', $cacheLimiter); ini_set('session.cache_limiter', $cacheLimiter); return $this; } /** * Set session.hash_function * * @param string|int $hashFunction * @return SessionConfig * @throws Exception\InvalidArgumentException */ public function setHashFunction($hashFunction) { $hashFunction = (string) $hashFunction; $validHashFunctions = $this->getHashFunctions(); if (!in_array($hashFunction, $validHashFunctions, true)) { throw new Exception\InvalidArgumentException('Invalid hash function provided'); } $this->setOption('hash_function', $hashFunction); ini_set('session.hash_function', $hashFunction); return $this; } /** * Set session.hash_bits_per_character * * @param int $hashBitsPerCharacter * @return SessionConfig * @throws Exception\InvalidArgumentException */ public function setHashBitsPerCharacter($hashBitsPerCharacter) { if (!is_numeric($hashBitsPerCharacter) || !in_array($hashBitsPerCharacter, $this->validHashBitsPerCharacters) ) { throw new Exception\InvalidArgumentException('Invalid hash bits per character provided'); } $hashBitsPerCharacter = (int) $hashBitsPerCharacter; $this->setOption('hash_bits_per_character', $hashBitsPerCharacter); ini_set('session.hash_bits_per_character', $hashBitsPerCharacter); return $this; } /** * Retrieve list of valid hash functions * * @return array */ protected function getHashFunctions() { if (empty($this->validHashFunctions)) { /** * @link http://php.net/manual/en/session.configuration.php#ini.session.hash-function * "0" and "1" refer to MD5-128 and SHA1-160, respectively, and are * valid in addition to whatever is reported by hash_algos() */ $this->validHashFunctions = array('0', '1') + hash_algos(); } return $this->validHashFunctions; } /** * Handle PHP errors * * @param int $code * @param string $message * @return void */ protected function handleError($code, $message) { $this->phpErrorCode = $code; $this->phpErrorMessage = $message; } }