开发者

Errors With PHP Session [duplicate]

This question already has answers here: How to fix "Headers already sent" error in PHP (11 answers) Closed 9 开发者_Go百科years ago.

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'); ?>


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


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.


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

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


Start your session before you include header.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜