0

Please, with my PGRFileManager.php (with my ckeditor), The visitors can unfortunately access to file to this adress : http://my-web-site.com/ckeditor/plugins/pgrfilemanager/PGRFileManager.php

To secure I want to ensure that if it is not a user of my admin, redirect (exit) the visitor ...

At Login I create a new 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
  ...
 }
}

 
OK. _But the prolem, in my PGRFileManager.php, with this code :
<?php
session_start();
var_dump($_SESSION['usercms']);

Wamp return this error : "Notice: Undefined index: usercms in C:\wamp\www___Laravel\my-web-site\ckeditor\plugins\pgrfilemanager\PGRFileManager.php on line 4"

What is the solution please? Thank You.

stephweb
  • 125
  • 2
  • 16

1 Answers1

0

Check if the key 'usercms' exists in the session.

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

See answers here: PHP Undefined Index

Community
  • 1
  • 1
cidermole
  • 5,662
  • 1
  • 15
  • 21