Does anyone have an example or even a use case for Zend_Session_Validator_HttpUserAgent
I can't seem to get this to work even in it's most basic form.
bootstrap file:
PHP Code:
$session = array(
'name' => $config->application->name,
'save_path' => $cwd.DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'sessions',
'use_only_cookies' => 'on',
'remember_me_seconds' => 60
);
Zend_Session::setOptions($session);
try
{
Zend_Session::start();
}
catch (Zend_Session_Exception $e)
{
Zend_Debug::dump($e, 'error');
die;
}
Zend_Session::registerValidator(new Zend_Session_Validator_HttpUserAgent());
....
To test the HTTP user agent change, I use the "change browser identification" tool in Konqueror
I've tried putting the Zend_Session::registerValidator(.... at different positions.
But regardless...
I can't seem to get Zend_Session to throw the error as stated in the
Zend_Session --> _processValidators() function when the user agent has changed.
Zend_Session:
PHP Code:
/**
* _processValidator() - internal function that is called in the existence of VALID metadata
*
* @throws Zend_Session_Exception
* @return void
*/
private static function _processValidators()
{
if (count($_SESSION['__ZF']['VALID']) > 0) {
/**
* @see Zend_Loader
*/
require_once 'Zend/Loader.php';
}
foreach ($_SESSION['__ZF']['VALID'] as $validator_name => $valid_data) {
Zend_Loader::loadClass($validator_name);
$validator = new $validator_name;
if ($validator->validate() === false) {
throw new Zend_Session_Exception("This session is not valid according to {$validator_name}.");
}
}
}
My goal here is to catch when the user agent has changed in mid session for logging.
Any ideas??