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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session cookies

Status
Not open for further replies.

lothadio

Programmer
Apr 5, 2001
27
SI
**************Why an I getting this Warning?****************

Warning: Cannot send session cookie - headers already sent by (output started at c:\inetpub\ in c:\inetpub\ on line 4



*****************This is my code**************************

<?
session_start();
session_register(&quot;user&quot;);

//check to see if $your_name contains a value

if (!empty($user))
{
echo (&quot;$user&quot;);
}

//this is the form that grabs your variable information

elseif (empty($user) && !isset($submit))
{
echo (&quot;<form name=\&quot;user validation\&quot; method=\&quot;post\&quot; action=$PHP_SELF>
<input type=\&quot;text\&quot; name=\&quot;user_name\&quot;><br>
<input type=\&quot;text\&quot; name=\&quot;password\&quot;><br>
<input type=\&quot;submit\&quot; name=\&quot;submit\ value=\&quot;submit\&quot;>
</form>&quot;);
}
elseif (isset($submit) && empty($user))
{
$name_of_variable=($user_name);

echo ($user);
}
?>
 
Warning: Cannot send session cookie - headers already sent

.. this means that there must be code before the session_start. try the session start before nay html in the page and check for a blank line at the beginning. the script that starts the session needs to be the first thing on the page ...

Steve
 
Sometimes occurs that first line in script is white (Or somespace bar), and
Php read it as html.
Try with the first caracter in the script must be '<?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top