如何在cakePHP中将同一对象的多个条目添加到会话中

如何在cakePHP中将同一对象的多个条目添加到会话中,cakephp,Cakephp,我有一个addstudent.ctp文件来添加学生 echo $this->Form->create('Student'); echo $this->Form->input('FirstName'); echo $this->Form->input('LastName'); echo $this->Form->end('Register'); echo $this->Form->create('Address',array('con

我有一个addstudent.ctp文件来添加学生

echo $this->Form->create('Student');
echo $this->Form->input('FirstName');
echo $this->Form->input('LastName');
echo $this->Form->end('Register'); 

echo $this->Form->create('Address',array('controller'=>'addresses','action'=>'addaddress'));
echo$this->Form->end('NextAdressDetails',array('controller'=>'addresses','action'=>'addaddress')); 
单击后,它将添加StudentsController方法。它必须将student对象添加到会话,并应重定向到同一页面。这样,我可以添加尽可能多的学生,因此我的问题是如何在每次单击register按钮时将多个学生添加到会话中

$students = $this->Session->read('Students');
if (!$students) {
    $students = array();
}
$students[] = /* data */;
$this->Session->write('Students', $students);