Jump to content

session_start(): cannot send session cache limiter


warrens0017

Recommended Posts

Good day everyone,

I am running into this error: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/.../accedit.php:1) in /home/.../accedit.php:2";

i have looked it up but all I am getting is there is white space that is causing this issue. This is the top part of this code:

<?php
session_start();
include '../inc/inc.php';
?>

Here is the inc.php:

<?php
include "../inc/dbh.php";
include '../inc/header.php';
include '../inc/bg_img_page.php';
include '../inc/nav.php';
    
include 'info_get.php';
include 'info_set.php';
include 'info_edit.php';
include 'info_view.php';

 

Link to comment
Share on other sites

It is at the very top of document before the doctype and any html whatsoever, yes! Also none of the other included files do not include session_start() either, yes! And theres definitely no line break, space before <?php or space after. Any of these will cause already open header error.

Link to comment
Share on other sites

According to the error message, output started on line 1. It could be that your file is encoded as UTF-8 with a Byte-Order Mark (BOM). The BOM are three bytes that appear at the beginning of the file and may be invisible in your editor. To make sure this does not happen, open the file in a code editor and make sure that the encoding of the file is UTF-8 without a BOM.

Link to comment
Share on other sites

It's saying that the output starts on the line before you use session_start, and the only thing you're showing on that line is the opening PHP tag.  Assuming there is not a space before the opening PHP tag, it's got to be the BOM.  The BOM does not appear as a character in the text editor, but it's there when it saves the file, and like anything else outside of the PHP block, PHP will send all of that as output to the browser.  You need to explicitly save without the BOM.  In Sublime, that's File -> Save With Encoding -> UTF-8.  When you open a file without a BOM in Sublime and just hit save, it will not add the BOM back if it isn't already there, you don't need to always save files like that after you do it once.  Although other editors might add it back in without you telling it to.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...