Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  How-Tos  >  How to Fix CodeIgniter Error, “A PHP Error was Encountered”?
Top Scroll

How to Fix CodeIgniter Error, “A PHP Error was Encountered”?

 2 min

CodeIgniter generally shows, “A PHP error was encountered,” when there are issues in the codes that have been used in the website.

In this article, we will understand the reasons why this CodeIgniter error occurs and the steps to fix it.

Why Does CodeIgniter, “A PHP Error was Encountered” Appears?

Besides, there are other reasons this error could be triggered, such as using poor codes structures or any type of issue with the database server.

When this error encounters, you see an error message in the below format:

A PHP Error was encountered
Severity: Warning

Message: ini_set(): A session is active. You cannot change the session module's ini settings at this time
Filename: Session/Session.php

Line Number: 284


File: /home/cPanelusername/public_html/
Line: 8
Function: __construct

File: /home/cPanelusername/public_html/
Line: 318
Function: require_once
PHP Error Encountered


  • Severity: Specifies whether the issue is major or minor. It can be in the form or Notice or Warning.
  • Message: Shows information about the nature of the error.
  • File Name: The file name which is causing the issue.
  • Line Number: The line for checking such error.

Steps to Fix the CodeIgniter Error, “A PHP Error was Encountered”

Here are the steps to fix the CodeIgniter, “A PHP Error was Encountered”:

Step 1

Open file application/config/config.php and replace http with https like below.

$path = “https://”.$_SERVER[‘HTTP_HOST’].str_replace(basename($_SERVER[‘SCRIPT_NAME’]),””,$_SERVER[‘SCRIPT_NAME’]);

Step 2

In application/config/config.php ; sess_save_path should be set as below. Create ci_sessions directory in application folder in domain’s document root and update ownership

$config[‘sess_save_path’] = APPPATH . ‘ci_sessions/’;

Step 3

In index.php find for session_start(); and comment it as below



Thus by following the above steps, you can fix the CodeIgnitor error, “A PHP Error was encountered”.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.