I get a warning and cannot start a session. I understand from reading
through the documentation and other posts that session_start must occur in
the php script before any HTML tags or output to the browser. In my
script, the session_name and session_start are the first two lines in
thescript; so I can't see what the problem could be.
I have used sessions on other pages in a similar fashion (in the same web
project, on the same server) and do not have any problems.
I would greatly appreciate if anyone has any ideas of what could be causing
the problem.
The warning as reported by the web server is as follows:
----------
Warning: Cannot send session cookie - headers already sent by (output
started at /home/parking2/secure_html/ControlPanel/adminCtrl.php:2) in
/home/parking2/secure_html/ControlPanel/adminCtrl.php on line 4
Warning: Cannot send session cache limiter - headers already sent (output
started at /home/parking2/secure_html/ControlPanel/adminCtrl.php:2) in
/home/parking2/secure_html/ControlPanel/adminCtrl.php on line 4
-----------
// The first lines of my php script source code are as follows:
<?php
session_name("report_page");
session_start();
include '../vars.php';
// Get variables from forms:
if (!empty($HTTP_POST_VARS)) while(list($name, $value) =
each($HTTP_POST_VARS)) $$name = $value;
show_page_header();
if ($logout)
{
$_SESSION['time'] = 0;
}
if(!($_SESSION['time'] > (time() - 3600) ))
{
do_login();
exit;
}
// end php code snippet ------------------------------------------