/**
  * Saves state in session.
  * @param mixed state to be stored
  */
 public function save($state)
 {
     $session = $this->_page->getSession();
     $session->open();
     $data = serialize($state);
     $timestamp = (string) microtime(true);
     $key = self::STATE_SESSION_KEY . $timestamp;
     $session->add($key, $data);
     if (($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) {
         $queue = array();
     }
     $queue[] = $key;
     if (count($queue) > $this->getHistorySize()) {
         $expiredKey = array_shift($queue);
         $session->remove($expiredKey);
     }
     $session->add(self::QUEUE_SESSION_KEY, $queue);
     $this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $timestamp));
 }
 /**
  * Saves state in hidden fields.
  * @param mixed state to be stored
  */
 public function save($state)
 {
     $this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $state));
 }
 /**
  * Saves state in cache.
  * @param mixed state to be stored
  */
 public function save($state)
 {
     $data = serialize($state);
     $timestamp = (string) microtime(true);
     $key = $this->calculateKey($timestamp);
     $this->getCache()->add($key, $data, $this->_timeout);
     $this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $timestamp));
 }