View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}



1.0 - 13 November 2007: Initial release

Zend_Session_ValidatorMagicString is almost a copy of Zend_Session_ValidatorHttpUserAgent with an exception, that it stores a custom value in client's cookie on session creation and verifies it on every session resume

* [Component Page on|]

Nothing special requried to use this component

* This component *will not* save any data using Zend_Cache or the filesystem. All transient data *will be* saved using Zend_Session and client cookies

* Zend_Session

The component is instantized by executing Zend_Sesion::registerValidator(new Zend_Session_Validator_MagicString('Key', 'Value'));

The component is so simple, that it does not require any milestones

* Zend_Session_ValidatorMagicString

||UC-01||You want to validate session against custom cookie value stored at session creation

require_once "Zend/Session.php"
try {
Zend_Session::start(); //Starting session
} catch (Zend_Session_Exception $e) {
//Unable to create session. Possibly, session validation failed
//(For example, UserAgent or IP address is changed on client. We can get reason from $e->getMessage())

//Doing something and finding out that there is a need to remember this session data
if($needToKeepThisSession) {
Zend_Sesion::registerValidator(new Zend_Session_Validator_HttpUserAgent()); //Registering first validator
Zend_Sesion::registerValidator(new Zend_Session_Validator_MagicString('MyKey', 'MyValue')); //Registering second validator