Web Hosting Talk







View Full Version : Help related to php (Session Cookie)


jainritesh
10-01-2009, 02:45 AM
Dear All
I have modified my code at www.hostlx.com/order (http://www.hostlx.com/order) to insert header but after inserting header i'm always getting following error

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/hostlxco/public_html/order/index.php:5) in /home/hostlxco/public_html/order/index.php on line 18

Source Code of Page



<BODY>
<?PHP
SESSION_START();
INCLUDE "config.php";
INCLUDE "/home/hostlxco/public_html/library/whm.php";
INCLUDE "/home/hostlxco/public_html/include/global.php";
$page = "$_GET[page]";
if (empty($page)) {
$page = 'list';
}
?>
<table width="760" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td background="../images/header.jpg" width="780" height="212" alt="Hostlx.com" style="vertical-align:bottom"><table width="745" height="81" align="center" cellpadding="1">
<tr>
<td width="173" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:42px; color: #666; font-family: Arial; font-size: 15px;">&nbsp;&nbsp;&nbsp;
<a href="http://www.hostlx.com"><font color="#666666">Home</font></a></div></td>
<td width="138" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:46px; color: #666; font-family: Arial; font-size: 15px;"><a href="http://www.hostlx.com/order"><font color="#666666">Plan</font></a></div></td>
<td width="139" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:7px; color: #666; font-family: Arial; font-size: 14px;""><a href="http://www.hostlx.com/client"><font color="#666666">Client Area</font></a></div></td>
<td width="139" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:37px; color: #666; font-family: Arial; font-size: 15px;""><a href="http://www.hostlx.com/terms.html"><font color="#666666">Terms</font></a></div></td>
<td width="139" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:28px; color: #666; font-family: Arial; font-size: 15px;"><a href="http://www.hostlx.com/support/"><font color="#666666">Support</font></a></div></td>
</tr>
</table></td>
</tr>
</table>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="60%" ALIGN="CENTER">
<TR>
<TD><IMG SRC="../images/bx_1.jpg" WIDTH="14" HEIGHT="15"></TD>
<TD BACKGROUND="../images/bx_top.jpg">&nbsp;</TD>
<TD><IMG SRC="../images/bx_2.jpg" WIDTH="14" HEIGHT="15"></TD>
</TR>
<TR>
<TD BACKGROUND="../images/bx_left.jpg">&nbsp;</TD>
<TD WIDTH="100%">
<?PHP
include"$svr_rootscript/order/$page.php";
?>
</TD>
<TD BACKGROUND="../images/bx_right.jpg">&nbsp;</TD>
</TR>
<TR>
<TD><IMG SRC="../images/bx_3.jpg" WIDTH="14" HEIGHT="15"></TD>
<TD BACKGROUND="../images/bx_bottom.jpg">&nbsp;</TD>
<TD><IMG SRC="../images/bx_4.jpg" WIDTH="14" HEIGHT="15"></TD>
</TR>
</TABLE>
<div id="footer">
<div class="indent">&nbsp;
<p align="center"><font face="Arial" size="2"><a href="http://www.hostlx.com/index.html"><font color="#FF6600">Home</font></a><font color="#FF6600"> &nbsp; &nbsp; | &nbsp; &nbsp;
</font><a href="http://www.hostlx.com/client"><font color="#FF6600">Client Area</font></a><font color="#FF6600"> &nbsp; &nbsp; | &nbsp; &nbsp;
</font><a href="http://www.hostlx.com/support"><font color="#FF6600">Support</font></a><font color="#FF6600"> &nbsp; &nbsp; | &nbsp; &nbsp;
</font><a href="http://www.hostlx.com/privacy-policy.html"><font color="#FF6600">Privacy Policy</font></a><font color="#FF6600"> &nbsp; &nbsp; | &nbsp; &nbsp;
</font><a href="http://www.hostlx.com/terms.html"><font color="#FF6600">Terms of Service</font></a><font color="#FF6600"> &nbsp; &nbsp; | &nbsp; &nbsp; <a href="http://www.hostlx.com/billing-policy.html"><font color="#FF6600">Billing Policy</font></a> &nbsp; &nbsp; | &nbsp; &nbsp;
<a href="http://www.hostlx.com/abuse-terms.html"><font color="#FF6600">Abuse Terms</font></a>
</font></font></p>
<p align="center"><font size="2" face="Arial">Copyright &copy; HOSTLX.com 2009</font></p></div>
</div>
</BODY>



If i Remove the following code from above the same works fine:



<table width="760" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td background="../images/header.jpg" width="780" height="212" alt="Hostlx.com" style="vertical-align:bottom"><table width="745" height="81" align="center" cellpadding="1">
<tr>
<td width="173" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:42px; color: #666; font-family: Arial; font-size: 15px;">&nbsp;&nbsp;&nbsp;
<a href="http://www.hostlx.com"><font color="#666666">Home</font></a></div></td>
<td width="138" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:46px; color: #666; font-family: Arial; font-size: 15px;"><a href="http://www.hostlx.com/order"><font color="#666666">Plan</font></a></div></td>
<td width="139" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:7px; color: #666; font-family: Arial; font-size: 14px;""><a href="http://www.hostlx.com/client"><font color="#666666">Client Area</font></a></div></td>
<td width="139" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:37px; color: #666; font-family: Arial; font-size: 15px;""><a href="http://www.hostlx.com/terms.html"><font color="#666666">Terms</font></a></div></td>
<td width="139" align="right" valign="middle"><div class="menucss" style="padding-top:14px; padding-right:28px; color: #666; font-family: Arial; font-size: 15px;"><a href="http://www.hostlx.com/support/"><font color="#666666">Support</font></a></div></td>
</tr>
</table></td>
</tr>
</table>




Please Guide.

Thanks in advance.

Best Regards,
Ritesh Jain

jainritesh
10-01-2009, 06:30 AM
Hello All,
I have found the solutions.

Thankyou,

Regards,
Ritesh Jain

TheServerExperts
10-01-2009, 08:52 AM
Hi, it would be nice to share with WHT how you fix it, so future users can help themself.

fabin
10-01-2009, 10:37 AM
session_start() is supposed to be used at the very beginning of the file.. anyway its not going to work if its used after <body> tag :)

jainritesh
10-01-2009, 01:43 PM
Hello!
Exactly as fabin said, i moved the following code at the top of the script i.e. above <head> and it worked.


<?PHP
SESSION_START();
INCLUDE "config.php";
INCLUDE "/home/hostlxco/public_html/library/whm.php";
INCLUDE "/home/hostlxco/public_html/include/global.php";
$page = "$_GET[page]";
if (empty($page)) {
$page = 'list';
}
?>

<head>
...

Regards,
Ritesh Jain