symfonyでセッションを使う

以下のようになる

public function executeIndexSuccess()
  {
    $username= $this->getRequestParameter('username');
    $this->getUser()->setAttribute('username', $username);
  }

アクションaction.class.php

public function executeIndex()
{
  $this->setFlash('flashname', md5(uniqid(time())) );
}

ビューindexSuccess.php

<div>
<?php use_helper('Validation') ?>
  <?= form_tag('mymodule/do') ?>  ←doへsubmit
  <?php echo input_hidden_tag('uniqid', 
$sf_flash->get('flashname')) ?>  ←hiddenでflashnameを送る
  </form>
</div>

アクションに以下を加える。

public function executeDo()
{
 if( $this->getFlash('flashname') !== $this->getRequestParameter("uniqid") ){
  $this->logMessage("二重投稿です");
  $this->forward404();
 }
 else{
  // 投稿処理
 }