I have a couple of PHP pages which begins with a secure session start. When I put a page title in the head section it says "headers already passed". How can I put page titles while securely starting a PHP function at the beginning of the page?
Asked
Active
Viewed 169 times
-1
-
Please post your code if possible. – dakshbhatt21 Jul 08 '13 at 10:14
-
Put your title tag after the php code – Dale Jul 08 '13 at 10:15
-
You need tp look at the line the error message is complaining about. Starting a session and then outputting the HTML should never be a problem. – Pekka Jul 08 '13 at 10:15
-
Have a look at http://stackoverflow.com/a/8028987/2493019 – Lave Loos Jul 08 '13 at 10:19
1 Answers
1
If you are using session_start() Place your php script before any HTML code.
You cannot use or have an output before session_start()
not even an echo
.
e.g.
<?php
session_start();#creates a session or resumes the current
include(lib/inc.php);
?>
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<head>
<body>
<p>text</p>
<body>
</html>
An other solution if you must have an output is to use ob_start
http://php.net/manual/en/function.ob-start.php

fredtma
- 1,007
- 2
- 17
- 27