-1

This was working just fine with XAMPP on my local computer but started throwing this error when I uploaded it.

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/../admin/header.php:39) in /home/../admin/session.php on line 3

Here is a section of the code

<?php include('header.php'); ?>
<?php include('session.php'); ?>
<body>
<?php include('navbar.php') ?>
<div class="container-fluid">
<div class="row-fluid">
Dharman
  • 30,962
  • 25
  • 85
  • 135
Alfred Kimotho
  • 99
  • 3
  • 17
  • 1
    session_start() needs to be on the VERY top of your page. before headers. – Dimi Apr 06 '17 at 15:06
  • also, modify your session.php script to be something like this if it is not already `if (session_status() == PHP_SESSION_NONE) { session_start(); }` – Dimi Apr 06 '17 at 15:09
  • Do you have any HTML placed ABOVE this snippet of code you are showing us? – RiggsFolly Apr 06 '17 at 15:20

1 Answers1

0

Remove useless open/close tags

<?php 
include('header.php'); 
include('session.php'); 
?>

because the part after ?> and before the next <?php has/can have a line-break or tabs that generates output.

And better move include('session.php'); above the other include as @Dimi sayed.

JustOnUnderMillions
  • 3,741
  • 9
  • 12
  • I think you will find it is more useful to place `include('session.php'); ` first, as we have to assume that `include('header.php');` is going to be sending something to the browser. Not my DV – RiggsFolly Apr 06 '17 at 15:12
  • @RiggsFolly We dont know whats happen in that files (maybe it si only setting headers, as we thing session only makes a session;-)), so i pointing to the open/close tags. Then i have added the note from the comment, because that is also a point. By the way: what means `DV` ? – JustOnUnderMillions Apr 06 '17 at 15:15
  • But I think it is safe to assume there is some output in `header.php` based on the error. Your open close tag suggestion should make no difference assuming there are no hidden spaces in there as well – RiggsFolly Apr 06 '17 at 15:17
  • There is also likely to be a whole bunch of HTML above the snippet the OP showed us, based on the statement _here is a section of the code_ – RiggsFolly Apr 06 '17 at 15:19
  • @RiggsFolly I always go with the _possible_ issues that can happen and try not _assuming_ so mutch. Better is a answer that explains why the error is thrown. People need to learn , not only fix stuff (mostly by others). But nice to have a chat whit you. You are taking more time for something like that, then OP's in the first place for the hole question. And as always: Not here for points. – JustOnUnderMillions Apr 06 '17 at 15:24
  • :) I find it is better to read between the lines. Most questions are rushed and badly asked. 80% of the time because the OP has to ask they have no idea what might actually be a cause for the issue at hand. Between the lines is normally where you find the real question and the real problems. – RiggsFolly Apr 06 '17 at 15:29
  • @RiggsFolly Thing we match in many cases (how to handle so q), maybe i was to lazsy at the question, or just taken the first assumtion i had :-) Reading between lines is a must have feature for people that whant give help here. ;-) see ya – JustOnUnderMillions Apr 06 '17 at 15:31