Jump to content

[SOLVED] SESSION_HANDLING help


dkoolgeek

Recommended Posts

I am making a php website for a school asignment.

I am having a problem witht the following php script:

<?php
session_start();
include("Header.php");
?>

And I am getting the following error.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\eBiz 07\index.php:6) in C:\wamp\www\eBiz 07\index.php on line 7

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\eBiz 07\index.php:6) in C:\wamp\www\eBiz 07\index.php on line 7

Any help would be appreciated. Thanks
Link to comment
https://forums.phpfreaks.com/topic/30890-solved-session_handling-help/
Share on other sites

I have a lot more code. I need to use sessions to keep track on wether a user is logged in or not. I have the code done, i just can't start the session.



REST OF INDEX.php

<html>
<head></head>

<?php
session_start();
include("Header.php");
?>

<style type="text/css">
.style4 {font-size: 18px}
.style6 {font-size: 14px}
.style8 {font-family: "Family Guy", "Felix Titling"}
a:link {
color:#0099FF}
a:visited{
color:#CC99FF}
table{
color:#FFFFFF}
a:hover img{ filter:Alpha(Opacity=50)Wave(Add=0,  Freq=5,  LightStrength=20,  Phase=220,  Strength=10);}
a img
{
       border-width: 0px;
}
 
</style>

</head>
<body bgcolor="#505050">

<table width="932" border="0">
  <tr>
    <td width="187" height="152"><a href = "search.php"><img src="AllTheRightReasons.jpg" width="141" height="132"></a></td>
    <td width="190"><a href = "search.php"><img src="Sam%27sTown.jpg" width="128" height="128"></a></td>
    <td width="146"><a href = "search.php"><img src="TAAR.jpg" width="140" height="140"></a></td>
    <td width="167"><a href = "search.php"><img src="HTDMAAB.jpg" width="150" height="150"></a></td>
    <td width="220" rowspan="3"><div align="center" class="style4">
      <p class="style8">The Best Media Trading Site Online...Period</p>
      <p class="style6">With an unlimited number of volumes</p>
      <p class="style6"> in CDs, DVDs, Games, and Books </p>
      <p class="style6">we are simply the only place to go to</p>
      <p class="style6"> trade your media. Go ahead and get </p>
      <p class="style6"><a href="Login.php">registered</a>...you're the one missing </p>
      <p class="style6">out.</p>
      <p class="style6"> <br>
      </p>
    </div></td>
  </tr>
  <tr>
    <td align = "left"><a href = "search.php"><img src="Accepted.jpg" width="180" height="272"></a></td>
    <td colspan="3"><a href = "search.php"><img src="POTC.jpg" width="171" height="270"></a><a href = "serach.php"><img src="Simpsons.jpg" width="320" height="239"></a></td>
  </tr>
  <tr>
    <td height="257" colspan="2"><a href = "search.php"><img src="The%20Broker.jpg" width="167" height="254"></a><a href = "search.php"><img src="TheWorldIsFlat.jpg" width="186" height="255"></a></td>
    <td colspan="2"><a href = "search.php"><img src="box.jpg" width="153" height="217"></a><a href = "search.php"><img src="SplinterCell_Box.jpg" width="140" height="198"></a></td>
  </tr>
</table>
</body>
</html>


HEADER.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Trademymedia.com</title></head>

<style type="text/css">
a:link {
color:#0099FF}
a:visited{
color:#CC99FF}
font{
color:#FFFFFF}
p{ color:#FFFFFF}
</style>

<body bgcolor = "#505050">


<font color = "White"></font>
<table width="884" height="185" border="0" align = "center">
  <tr align = "center">
    <td width="445" height="74" rowspan="2"><img src="Logo.jpg" width="406" height="104"></td>
    <td height="122" colspan="3">
<?php
session_start();

if $_SESSION['in'] = TRUE {
$LogOut = "<a href = "Logout.php">Log Out</a>"
print $LogOut;}
else{
include "Login.php";}
?>
      </td>
  </tr>
  <tr>
    <td width="57" height="21"><div align="center"><a href="index.php">Home</a></div></td>
    <td width="68"><div align="center"><a href="about.php">About</a></div></td>
    <td width="98"><div align="center"><a href="MyAccount.php">My Account</a></div></td>
  </tr>
</table>
<hr>
looking at your code now, session_start needs to be right at the top of your page. no html (or output of any kind) can be sent before headers/sessions. move session_start to the top of your code (obviously within a < ?php  ?> block

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.