2015-10-06 90 views
0

請與我PGRFileManager.php(與我的CKEditor), 遊客可遺憾的是進入文件到這個地址: http://my-web-site.com/ckeditor/plugins/pgrfilemanager/PGRFileManager.phpLaravel 5 - 恢復會話PGRFileManager.php

爲了確保我希望確保如果不是我的管理員的用戶,重定向(出口)的遊客......

在登錄我創建一個新的會話「usercms」:

<?php 
 
public function postLogin(Request $request) 
 
{ 
 
\t $login = Auth::attempt([ 
 
\t \t \t \t \t \t \t 'username' => $request->input('username'), 
 
\t \t \t \t \t \t \t 'password' => $request->input('password') 
 
\t \t \t \t \t \t ], $request->input('remember')); 
 

 
\t if ($login) { 
 
\t \t Session::put('usercms', 'EXISTE'); // CREATE SESSION 
 
\t \t ... 
 
\t } 
 
} 
 

 
\t
好的。 _but的prolem,在我PGRFileManager.php,使用此代碼:

<?php 
session_start(); 
var_dump($_SESSION['usercms']); 

WAMP這個錯誤: 「通知:未定義指數:用C usercms:\ WAMP \ WWW ___ Laravel \我的web站點\ ckeditor \ plugins \ pgrfilemanager \ PGRFileManager.php on line 4「

請問有什麼解決方法? 謝謝。

回答

0

檢查會話中是否存在密鑰「usercms」。

<?php 
session_start(); 
if(isset($_SESSION['usercms']) && $_SESSION['usercms'] == 'EXISTE') { 
    // good 
} else { 
    die('Unauthorized.'); 
} 

看到這裏的答案: PHP Undefined Index

+0

感謝,但沒有事實並非如此。雖然我認證是死(「未經授權」),它出現了 – stephweb