Source for file Session.php

Documentation is available at Session.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Session.php
  5.  *
  6.  *  @author     Keita Arai <cocoiti@comio.info>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: dbf2caabef9b39d7bf03a5f83ff9cfb5f2c2e926 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Csrf_Session
  13. /**
  14.  *  CSRF対策
  15.  *
  16.  *  CSRF対策をトークンを用いて対策するためのコード
  17.  *
  18.  *  @author     Keita Arai <cocoiti@comio.info>
  19.  *  @access     public
  20.  *  @package    Ethna
  21.  */
  22. {
  23.     /**
  24.      *  トークンをViewとローカルファイルにセットする
  25.      *
  26.      *  @access public
  27.      *  @return boolean  成功か失敗か
  28.      */
  29.     public function set()
  30.     {
  31.         if ($this->session->isStart()) {
  32.             $this->session->start();
  33.         }
  34.  
  35.         $token $this->session->get($this->token_name);
  36.         if ($token !== null{
  37.             return true;
  38.         }
  39.  
  40.         $key $this->_generateKey();
  41.         $this->session->set($this->token_name$key)
  42.  
  43.         return true;
  44.     }
  45.  
  46.     /**
  47.      *  トークンIDを取得する
  48.      *
  49.      *  @access public
  50.      *  @return string トークンIDを返す。
  51.      */
  52.     public function get()
  53.     {
  54.         if ($this->session->isStart()) {
  55.             $this->session->start();
  56.         }
  57.  
  58.         return $this->session->get($this->token_name);
  59.     }
  60.  
  61.     /**
  62.      *  トークンIDを削除する
  63.      *
  64.      *  @access public
  65.      */
  66.     public function remove()
  67.     {
  68.         if ($this->session->isStart()) {
  69.             $this->session->start();
  70.         }
  71.         $this->session->remove($this->token_name);
  72.     }
  73. }
  74. // }}}

Documentation generated on Fri, 11 Nov 2011 03:59:01 +0900 by phpDocumentor 1.4.3