[英]redirect losses session cakephp
我試圖將會話保存在用戶嘗試輸入的可變URL中(如果用戶未登錄),因此我重定向到登錄URL,一旦登錄成功,就重定向回請求的網站。 我的問題是它不保存會話變量,也不從一側或另一側保存會話變量。
這在appController中
if($this->action!='logout' && $this->action!='logout_cas' && $this->action!='login_cas' && $this->action!='login'){
if(isset($_SESSION['cas_user'])){
$_SESSION['url_user'] = Router::url('', true);
$this->redirect(array('controller'=>'users','action'=>'login_cas'));
}
}
這在函數login_cas中的UsersController中
if ($this->Auth->user('active') != '1') {
$active = $this->Auth->user('active');
$this->Session->destroy();
if($active < 0)
throw new Exception(__('Invalid user or password. Try again'));
throw new Exception(__('User blocked, contact your administrator'));
} else {
$_SESSION["user_login_errors"] = 0;
//$this->redirect(array('controller'=>'users','action'=>'home'));
$this->redirect($_SESSION['url_user']);
}
消息通知(8):未定義索引:url_user
當然,只有我的域網頁。 問題解決了,我的代碼在其他存儲庫中運行完美,克隆了站點,然后又恢復了工作。 無論如何,請聽取您的意見和建議
$this->Session->write
並閱讀CakePHP。 nk!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.