ブラウザセッションで保存したマップを使用することにしました。このようにして、URLを介してtokenKeyを渡し、後で変数を取得できます。
この小さな拡張クラスのZend_Session_Namespaceを作成し、「add」関数と「get」関数を追加しました。
<?php
class My_Session_Tokens extends Zend_Session_Namespace {
protected $_namespace = "Tokens";
public function __construct($namespace = 'Tokens', $singleInstance = false)
{
parent::__construct($namespace, $singleInstance);
}
public function add($token) {
if($tokenKey = $this->hasToken($token)) {
return $tokenKey;
}
do { $tokenKey = uniqid(); } while(isset($this->$tokenKey));
$this->$tokenKey = $token;
return $tokenKey;
}
public function get($tokenKey) {
if(isset($tokenKey)) {
return $this->$tokenKey;
}
return null;
}
public function hasToken($token) {
foreach($this as $key => $val) {
if($val === $token) return $key;
}
return false;
}
}