我的项目中有四个分支,当我点击branch1时,会话应该存储branch1,同样的方式分支2,3 ......
<?php foreach($val as $value) {?>
<tr>
<th><span><?php echo $this->Html->link($value['Branch']['branch_name'], array('controller' => 'branchs', 'action' => 'index','onclick'=> 'update')) ?></span></th>
<?php CakeSession::write('sa',$value['Branch']['branch_name']); ?>
</tr>
<?php } ?>
<tr>
答案 0 :(得分:1)
<?php foreach($val as $value) {?>
<tr>
<th><span>
<?php echo $this->Html->link($value['Branch']['branch_name'],array('controller' => 'branchs', 'action' => 'index','onclick'=> 'update')) ?></span>
</th>
<?php $this->Session->write('sa',$value['Branch']['branch_name']; ?>
</tr>
<?php } ?>
我的演示代码
$val=array('1','3','4');
foreach ($val as $key => $value) {
$this->Session->write('sa',$val);
}
$val1=$this->Session->read('sa');
foreach ($val1 as $key => $value) {
echo $value.'<br>';
}
我的演示输出