11-20-2018, 09:56 AM
I'm developing a pretty large project with CI4 and things have been working out pretty well so far. This is the first time I've run into an issue and cannot figure out why. php spark won't load with the following code in place:
C:\Users\Kyle\Desktop\OGD\framework>php spark serve
CodeIgniter CLI Tool - Version 4.0.0-alpha.2 - Server-Time: 2018-11-20 09:45:28am
An uncaught Exception was encountered
Type: ErrorException
Message: Undefined variable: _SESSION
Filename: C:\Users\Kyle\Desktop\OGD\framework\system\Session\Session.php
Line Number: 474
If I comment out the following code php spark serve will work:
I think the real offending line is:
I can run php -S localhost:8080 and it all works. Is this because the code is running through the CLI?
Any thoughts?
C:\Users\Kyle\Desktop\OGD\framework>php spark serve
CodeIgniter CLI Tool - Version 4.0.0-alpha.2 - Server-Time: 2018-11-20 09:45:28am
An uncaught Exception was encountered
Type: ErrorException
Message: Undefined variable: _SESSION
Filename: C:\Users\Kyle\Desktop\OGD\framework\system\Session\Session.php
Line Number: 474
If I comment out the following code php spark serve will work:
PHP Code:
<?php
namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
class AuthUser implements FilterInterface {
public function before(RequestInterface $request) {
$session = session();
$user = $session->get('user');
if (empty($user['id'])) {
return redirect('login');
}
}
public function after(RequestInterface $request, ResponseInterface $response) {
}
}
?>
I think the real offending line is:
PHP Code:
return redirect('login');
I can run php -S localhost:8080 and it all works. Is this because the code is running through the CLI?
Any thoughts?