Warning : session_start(): Cannot send session cache limiter - headers already sent even after using session_start() and ob_start()
I don't know, if your code is well formatted in your question. But if so, remove the blank space before <?php
.
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at
The session_start()
function should be on top of your file like this:
<?php
session_start(); // Should be on top when using $_SESSION
class Login {
private $db_connection = null;
public $errors = array();
public $messages = array();
public function __construct() {
// Rest of your scripts
This error caused because the headers where sent already so it is to late to load the session_handler()
either, that's why you have to put it on top of your file to load it with the headers.
If you use a framework that includes the pages, you only need to use the session_start()
once in the main file (e.g. index.php), where you include the other files
I hope this will help you.
PHP Warning: session_start(): Cannot send session cache limiter - headers already sentwhile the session_start is added at top
I cant comment put all your php codes before <!DOCTYPE html>
or in body tags!
Make sure you dont have spaces between <? php tags
. where you include files.
Turn on error reporting :
error_reporting(E_ALL);
ini_set('display_errors', 1);
Check error_log file in C:\wamp\logs\php_error.txt
if you are using wampserver on localhost.
Try testing for isset($_SESSION)
If it already exists then do not use session_start();
Look like you are passing second session start from another file try Like this :
if(!isset($_SESSION)){
session_start();
}
Use session_start()
before anything else.
Related Topics
How to Get CPU Usage and Ram Usage Without Exec
Laravel Catch Tokenmismatchexception
Convert Month from Name to Number
String Contains Any Items in an Array (Case Insensitive)
How Get All Values in a Column Using PHP
Codeigniter - Why Use Xss_Clean
Which Is Faster and Better, Switch Case or If Else If
Uploading a File in Chunks Using HTML5
Verify Imagemagick Installation
Convert Utc Dates to Local Time in PHP
Merge 'With' and 'Wherehas' in Laravel 5
Namespace in PHP Codeigniter Framework
Php, Simplexml, Decoding Entities in Cdata
Ssl Error Ssl3_Get_Server_Certificate:Certificate Verify Failed