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, the issues in the website code, there are other reasons this error could be triggered, such as poor code 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

Backtrace:

File: /home/cPanelusername/public_html/domain.com/application/controllers/Site.php
Line: 8
Function: __construct

File: /home/cPanelusername/public_html/domain.com/index.php
Line: 318
Function: require_once
php error encountered

Here:

  • 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 error, “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
//session_start();

Conclusion

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!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.