请使用我的PGRFileManager.php(与我的ckeditor),不幸的是,访问者可以访问到这个地址的文件:http://my-web-site.com/ckeditor/plugins/pgrfilemanager/PGRFileManager.php
为了确保安全,我想确保如果它不是我的admin的用户,重定向(退出)访问者…
在登录时,我创建了一个新的SESSION "usercms":
<?php
public function postLogin(Request $request)
{
$login = Auth::attempt([
'username' => $request->input('username'),
'password' => $request->input('password')
], $request->input('remember'));
if ($login) {
Session::put('usercms', 'EXISTE'); // CREATE SESSION
...
}
}
好的。但问题是,在我的PGRFileManager.php中,使用以下代码:
<?php
session_start();
var_dump($_SESSION['usercms']);
Wamp返回这个错误:"注意:未定义的索引:usercms在C:'wamp'www__ laravel 'my-web-site'ckeditor'plugins'pgrfilemanager' pgrfilemanager .php第4行"
请问解决方案是什么?谢谢你。
检查会话中是否存在'usercms'键
<?php
session_start();
if(isset($_SESSION['usercms']) && $_SESSION['usercms'] == 'EXISTE') {
// good
} else {
die('Unauthorized.');
}
请看这里的答案: