Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem: #3686

Closed
Muneeb1998 opened this issue Sep 26, 2020 · 6 comments
Closed

problem: #3686

Muneeb1998 opened this issue Sep 26, 2020 · 6 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@Muneeb1998
Copy link

i face error when i deploy CodeIgniter 4 project on hosting
CRITICAL - 2020-09-26 07:18:24 --> ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'ini_set(): Head...', '/home/p...', 43, Array)
#1 /home/mlnacta/public_html/habib_site/app/Controllers/BaseController.php(43): ini_set('session.save_pa...', '')
#2 /home/mlnacta/public_html/habib_site/vendor/codeigniter4/framework/system/CodeIgniter.php(891): App\Controllers\BaseController->initController(Object(CodeIgniter\HTTP\IncomingRequest), Object(CodeIgniter\HTTP\Response), Object(CodeIgniter\Log\Logger))
#3 /home/mlnacta/public_html/habib_site/vendor/codeigniter4/framework/system/CodeIgniter.php(399): CodeIgniter\CodeIgniter->createController()
#4 /home/mlnacta/public_html/habib_site/vendor/codeigniter4/framework/system/CodeIgniter.php(312): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#5 /home/mlnacta/public_html/habib_site/index.php(44): CodeIgniter\CodeIgniter->run()
#6 {main}
CRITICAL - 2020-09-26 07:18:24 --> Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /home/mlnacta/public_html/habib_site/app/Config/Events.php:27) in /home/mlnacta/public_html/habib_site/vendor/codeigniter4/framework/system/Debug/Exceptions.php:164
Stack trace:
#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Cannot modify h...', '/home/p...', 164, Array)
#1 /home/mlnacta/public_html/habib_site/vendor/codeigniter4/framework/system/Debug/Exceptions.php(164): header('HTTP/1.1 500 In...', true, 500)
#2 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException))
#3 {main}
thrown
#0 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
#1 {main}

@Muneeb1998 Muneeb1998 added the bug Verified issues on the current code behavior or pull requests that will fix them label Sep 26, 2020
@Muneeb1998 Muneeb1998 changed the title Bug: problem: Sep 26, 2020
@michalsn
Copy link
Member

  1. What CodeIgniter version are you using?
  2. Can you check if you have a line if (ini_get('zlib.output_compression')) in your app/Config/Events.php file?

@Muneeb1998
Copy link
Author

  1. What CodeIgniter version are you using?
  2. Can you check if you have a line if (ini_get('zlib.output_compression')) in your app/Config/Events.php file?
  1. i am using 4.0.4 version
  2. no

@paulbalandan
Copy link
Member

It seems your code in BaseController is throwing errors when setting the session path. Can you paste the contents of your BaseController?

@Muneeb1998
Copy link
Author

`<?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;
// JAK Cutom:
use App\Libraries\App;
// JAK Cutom;

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 = [];

/**
 * 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();
	if(isset($_GET['lang'])){
		$this->session->set(array(
			'lang' => $_GET['lang']
		));
	}
	// else{
	// 	$this->session->set(array(
	// 		'lang' => 'English'
	// 	));
	// }
	// print_r($_SESSION['lang']);
	// $r = (explode('/', uri_string(), 2));
	// JAK Cutom:
	$this->libraryApp 	= new App($this);
	helper('front');
	// JAK Cutom;
}

}
`

@enix-app
Copy link
Contributor

I guess these line:

$this->libraryApp = new App($this);
helper('front');

I don't know what's in it.

@michalsn
Copy link
Member

From your answer I see you upgraded to 4.0.4 from lower version, so you don't have a check against zlib.output_compression in place.

It's either the wrong sessionSavePath or enabled zlib.output_compression extension.

I will close this since the problem occurs only on your production server, but if none of the suggestions solve the problem, please feel free to continue the conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

4 participants