0

Just wondering if there are any alternative ways to use session_start() and also having my header.php in every page without getting the below warning? Help?

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

Here's the code.

<?php
session_start();
?>
<? include('header.php'); ?>
Jonah
  • 9,991
  • 5
  • 45
  • 79

4 Answers4

3

You should be calling session_start() before any output. Why can you not move the two around?

Prisoner
  • 27,391
  • 11
  • 73
  • 102
1

Make sure nothing is output when you run session_start(), it should be run once at the very start of your web page being requested.

This issue doesn't need resolving via JavaScript, you just need to restructure your code.

Jake N
  • 10,535
  • 11
  • 66
  • 112
1

Yes, you have to use session_start() before outputing anything.

If you use session_start() before including you header.php, this should work.

Arnaud Le Blanc
  • 98,321
  • 23
  • 206
  • 194
0

Start your session before you include header.php

Endophage
  • 21,038
  • 13
  • 59
  • 90