View Source

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

{zone-data:component-name}
Zend_Session_ValidatorMagicString
{zone-data}

{zone-data:proposer-list}
[FractalizeR@yandex.ru|mailto:FractalizeR@yandex.ru]
{zone-data}

{zone-data:revision}
1.0 - 13 November 2007: Initial release
{zone-data}

{zone-data:overview}
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
{zone-data}

{zone-data:references}
* [Component Page on SourceForge.net|http://zfsvalidators.sourceforge.net/]
{zone-data}

{zone-data:requirements}
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
{zone-data}

{zone-data:dependencies}
* Zend_Session
{zone-data}

{zone-data:operation}
The component is instantized by executing Zend_Sesion::registerValidator(new Zend_Session_Validator_MagicString('Key', 'Value'));
{zone-data}

{zone-data:milestones}
The component is so simple, that it does not require any milestones
{zone-data}

{zone-data:class-list}
* Zend_Session_ValidatorMagicString
{zone-data}

{zone-data:use-cases}
||UC-01||You want to validate session against custom cookie value stored at session creation
{zone-data}

{zone-data:skeletons}
{code}
<?php
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
Zend_Session::rememberMe();
}
?>
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>