我已經創建了登錄功能,一切工作正常。唯一的問題是我能夠訪問用戶控制器中的會話和用戶視圖。無法讀取蛋糕中的會話php
當我試圖訪問另一個控制器中的用戶會話時,它顯示我未定義。
以下是我的登錄功能代碼。
if ($this->Auth->login()) {
$user_data = $this->Auth->user();
$this->loadmodel('GeneralUser');
$result = $this->GeneralUser->find('first',array('conditions' => array('user_id' => $user_data['id'])));
$user_data_complete = array_merge($user_data,$result['GeneralUser']);
$this->Session->write('user',$user_data_complete);
$this->redirect('/dashboard/dashboard/');
$this->Session->setFlash('You are successfully logged in');
return $this->redirect($this->Auth->redirectUrl());
}
用戶已成功登錄並重定向到儀表板控制器,我無法訪問Auth用戶的會話。如果我回到用戶/ myaccount,我可以訪問會話。
奇怪,爲什麼我不允許訪問其他控制器中的用戶會話?
這是不正確的做法。你可以使用Session helper&component來做這件事。 – 2014-09-08 08:53:57