Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Header Problem

Status
Not open for further replies.

sipps

Technical User
Feb 9, 2003
133
GB
Hi,

I have had a problem with sessions, and passing data from one page to the next, but I thought I sorted it last night. Today it seems to be worse! All I want to do is pass some form data to the next page if a username exists, as I said, it worked fine last night, now I must have done something for it to stop working completely.

Here is the code:

<?php require_once('Connections/fmcrentals.php');?>

<?php
session_start();
session_register(&quot;Admin_Fname&quot;);
$HTTP_SESSION_VARS['Admin_Fname'] = $_POST['Admin_Fname'];
session_register(&quot;Admin_Lname&quot;);
$HTTP_SESSION_VARS['Admin_Lname'] = $_POST['Admin_Lname'];
session_register(&quot;Admin_DOB&quot;);
$HTTP_SESSION_VARS['Admin_DOB'] = $_POST['Admin_DOB'];
session_register(&quot;Admin_Email&quot;);
$HTTP_SESSION_VARS['Admin_Email'] = $_POST['Admin_Email'];
session_register(&quot;Admin_Password&quot;);
$HTTP_SESSION_VARS['Admin_Password'] = $_POST['Admin_Password'];

and the error message:

Warning: Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\rentals\adminaddadmin.php:3) in C:\Program Files\Apache Group\Apache2\htdocs\rentals\adminaddadmin.php on line 4

It also says that:

Warning: Cannot add header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\rentals\adminaddadmin.php:3) in C:\Program Files\Apache Group\Apache2\htdocs\rentals\adminaddadmin.php on line 51

and that line in the code is:

// *** Restrict Access To Page: Grant or deny access to this page
$FF_authorizedUsers=&quot; Admin&quot;;
$FF_authFailedURL=&quot;nopermission.php&quot;;
$FF_grantAccess=0;
session_start();
if (isset($HTTP_SESSION_VARS[&quot;MM_Username&quot;])) {
LINE 51.....if (false || !(isset($HTTP_SESSION_VARS[&quot;MM_UserAuthorization&quot;])) || $HTTP_SESSION_VARS[&quot;MM_UserAuthorization&quot;]==&quot;&quot; || strpos($FF_authorizedUsers, $HTTP_SESSION_VARS[&quot;MM_UserAuthorization&quot;])) {
$FF_grantAccess = 1;
}
}
if (!$FF_grantAccess) {
$FF_qsChar = &quot;?&quot;;
if (strpos($FF_authFailedURL, &quot;?&quot;)) $FF_qsChar = &quot;&&quot;;
$FF_referrer = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && strlen($HTTP_SERVER_VARS['QUERY_STRING']) > 0) $FF_referrer .= &quot;?&quot; . $HTTP_SERVER_VARS['QUERY_STRING'];
$FF_authFailedURL = $FF_authFailedURL . $FF_qsChar . &quot;accessdenied=&quot; . urlencode($FF_referrer);
header(&quot;Location: $FF_authFailedURL&quot;);
exit;
}

I am well stuck, please could anyone shed some light on my gloomy evening?!

Thank you
 
I have been putting session_start right at the top of each page, with the
session_register(&quot;Pick_Up_Time&quot;);
$HTTP_SESSION_VARS['Pick_Up_Time'] = $_POST['Pick_Up_Time'];
underneath it, will this cause any problems? It works fine on another page, and the values from the form get put in the session variables, but on this page they just dont get put in there.

It's really frustrating me! Any ideas? The reason I want to put these in session variables is the customer to choose to make a new booking, but leave and go off to another page, comeback and the booking info would still be there ready for him/her to carry on with.

Thanks sleipnir214.
 
From your error messages, adminaddadmin.php, in line 4, attempted to set a header after it had produced output in line 3.



As an aside, this page from the online manual tells us not to use session_register() if we are referencing $_SESSION (or $HTTP_SESSION_VARS) directly:
All you have to do is say $_SESSION['foo'] = 3 and the session variable is registered. Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top