Welcome Guest, Not a member yet? Register   Sign In
CI4 cannot start session
#1
Sad 

I add a line in Base Controller and run session. 

PHP Code:
<?php namespace App\Controllers;

/**
 * Class BaseController
 *
 * BaseController provides a convenient place for loading components
 * and performing functions that are needed by all your controllers.
 * Extend this class in any new controllers:
 *     class Home extends BaseController
 *
 * For security be sure to declare any new methods as protected or private.
 *
 * @package CodeIgniter
 */

use CodeIgniter\Controller;
use 
CodeIgniter\HTTP\IncomingRequest;
use 
Config\Database;

class 
BaseController extends Controller
{

    
/**
     * An array of helpers to be loaded automatically upon
     * class instantiation. These helpers will be available
     * to all other controllers that extend BaseController.
     *
     * @var array
     */
    
protected $helpers = [];
    protected 
$data = array();
        protected 
$session;
    protected 
$request;
    protected 
$db;

    
/**
     * Constructor.
     */
    
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
    {
        
// Do Not Edit This Line
        
parent::initController($request$response$logger);

        
//--------------------------------------------------------------------
        // Preload any models, libraries, etc, here.
        //--------------------------------------------------------------------
        // E.g.:
        
$this->session = \Config\Services::session();
        
        
// Connect Database
        
$this->db Database::connect();
        
        
// Request Income Data
        
$this->request service('request');        
    }




When I run my page, it show this massage :


Quote:Fatal error: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at C:\Users\hoffm\Dropbox\anaso\app\Config\Events.php:27) in C:\Users\hoffm\Dropbox\anaso\system\Debug\Exceptions.php:162 Stack trace: #0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Cannot modify h...', 'C:\\Users\\hoffm\\...', 162, Array) #1 C:\Users\hoffm\Dropbox\anaso\system\Debug\Exceptions.php(162): header('HTTP/1.1 500 In...', true, 500) #2 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #3 {main} thrown in C:\Users\hoffm\Dropbox\anaso\system\Debug\Exceptions.php on line 162

Fatal error: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at C:\Users\hoffm\Dropbox\anaso\app\Config\Events.php:27) in C:\Users\hoffm\Dropbox\anaso\system\Debug\Exceptions.php:162 Stack trace: #0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Cannot modify h...', 'C:\\Users\\hoffm\\...', 162, Array) #1 C:\Users\hoffm\Dropbox\anaso\system\Debug\Exceptions.php(162): header('HTTP/1.1 500 In...', true, 500) #2 C:\Users\hoffm\Dropbox\anaso\system\Debug\Exceptions.php(223): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #3 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #4 {main} thrown in C:\Users\hoffm\Dropbox\anaso\system\Debug\Exceptions.php on line 162


Do you have any suggestion for me ? please ~
Reply


Messages In This Thread
CI4 cannot start session - by hoffmanchan - 05-12-2020, 10:06 PM
RE: CI4 cannot start session - by InsiteFX - 05-13-2020, 03:17 AM
RE: CI4 cannot start session - by hoffmanchan - 05-13-2020, 04:00 AM
RE: CI4 cannot start session - by InsiteFX - 05-14-2020, 04:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB