zendframework/zf2-documentation — pull request #1342 by Martin-P (2014-08-11 23:14:24+00:00)
Title: Fixed bug in session manager code example

This PR fixes issue #1341.

The validators always returned true, because there was no reference data provided to the validators via the constructor. Therefore the validators used the default value (`$_SERVER['HTTP_USER_AGENT']`), see: [`Zend\Session\Validator\HttpUserAgent::__construct`](https://github.com/zendframework/zf2/blob/master/library/Zend/Session/Validator/HttpUserAgent.php#L27-L35).

When [`Zend\Session\Validator\HttpUserAgent::isValid()`](https://github.com/zendframework/zf2/blob/master/library/Zend/Session/Validator/HttpUserAgent.php#L43-L50) is called it compares the value with `$_SERVER['HTTP_USER_AGENT']`, see: [Zend\Session\Validator\HttpUserAgent::__construct](https://github.com/zendframework/zf2/blob/master/library/Zend/Session/Validator/HttpUserAgent.php#L27-L34), and thus always returns `true`.

This PR fixes the code example to make it work as it should. It now throws an exception when the user agent is changed.

> Zend\Session\Exception\RuntimeException: Session validation failed in ...\vendor\zf2\library\Zend\Session\SessionManager.php on line 111

The same applies for `Zend\Session\Validator\RemoteAddr` in that same example.