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,833
  • 5
  • 44
  • 79

4 Answers4

3

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

Prisoner
  • 26,783
  • 10
  • 71
  • 99
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,330
  • 9
  • 60
  • 108
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
  • 95,062
  • 22
  • 198
  • 192
0

Start your session before you include header.php

Endophage
  • 20,181
  • 10
  • 56
  • 87