Jump to content

Recommended Posts

Hi, I am getting a error/warning on the top of my page.

It looks like this:
[code]
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /vservers/shopmemo/htdocs/index.php:2) in /vservers/shopmemo/htdocs/library/config.php on line 11

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /vservers/shopmemo/htdocs/index.php:2) in /vservers/shopmemo/htdocs/library/config.php on line 11[/code]

Does anyone have any suggestions on how to fix this problem? Thanks in advance.

Nick
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/
Share on other sites

Hi, thanks for the quick response. However I am kind of new with PHP, can you tell me what that means. Thanks in advance.

Here is what the code looks like:
[code]<head>
<style type="text/css">
.style1 {
font-family: "Bauhaus 93";
}
.style4 {
font-size: xx-large;
}
</style>
</head>

<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId  = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

require_once 'include/header.php';
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142694
Share on other sites

[code]
<?php
ob_start();
session_start();
?>
<head>
<style type="text/css">
.style1 {
font-family: "Bauhaus 93";
}
.style4 {
font-size: xx-large;
}
</style>
</head>

<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId  = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

require_once 'include/header.php';
ob_end_flush();
?>
[/code]

add those three things...
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142809
Share on other sites

Thanks for you help, however now I am getting a notice.

[code]Notice: A session had already been started - ignoring session_start() in /vservers/shopmemo/htdocs/library/config.php on line 11[/code]

Here is what the code looks like so far.
[code]<?php
ob_start();
session_start();
?>
<head>
<style type="text/css">
.style1 {
font-family: "Bauhaus 93";
}
.style4 {
font-size: xx-large;
}
</style>
</head>

<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId  = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

require_once 'include/header.php';
ob_end_flush();
?>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%">
  <tr valign="top">
  <td width="164" valign="top" height="100%" background="images/index1_55.jpg"  id="leftnav">
<?php
require_once 'include/leftNav.php';
?>
[/code]

Any suggestions would be appreciated.
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142979
Share on other sites

Move the first four require_once statements to the beginning of your script.
[code]<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';
?>
<head>
<style type="text/css">
.style1 {
font-family: "Bauhaus 93";
}
.style4 {
font-size: xx-large;
}
</style>
</head>

<?php

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId  = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

require_once 'include/header.php';
ob_end_flush();
?>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%">
  <tr valign="top">
  <td width="164" valign="top" height="100%" background="images/index1_55.jpg"  id="leftnav">
<?php
require_once 'include/leftNav.php';
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142983
Share on other sites

I made those changes, however I get the warning message again.

[code]
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11[/code]

Here is what the full code looks like

[code]<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';
?>
<head>
<style type="text/css">
.style1 {
font-family: "Bauhaus 93";
}
.style4 {
font-size: xx-large;
}
</style>
</head>

<?php

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId  = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

require_once 'include/header.php';
ob_end_flush();
?>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%">
  <tr valign="top">
  <td width="164" valign="top" height="100%" background="images/index1_55.jpg"  id="leftnav">
<?php
require_once 'include/leftNav.php';
?>
  </td>
  <td>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr>
                <td width="100%" valign="top">
                  <p align="center" class="style1">&nbsp;Current Deals</td>
              </tr>
              </table>
<?php
if ($pdId)
{
require_once 'include/productDetail.php';
}
else if ($catId)
{
require_once 'include/productList.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return')
{
require_once 'include/return_policy.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='shipping')
{
require_once 'include/shipping.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_warranties')
{
require_once 'include/m_worranties.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='contact_us')
{
require_once 'include/contact_us.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return_request')
{
require_once 'include/return_request.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='website_issue')
{
require_once 'include/website_issue.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='feedback')
{
require_once 'include/feedback.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_website')
{
require_once 'include/m_website.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='about_us')
{
require_once 'include/about_us.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='privacy_policy')
{
require_once 'include/privacy_policy.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='aggrement')
{
require_once 'include/aggrement.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='search')
{
require_once 'include/search.php';
}
else
{
require_once 'include/categoryList.php';
}

?> 
  </td>
  <td  background="images/index1_55.jpg" width="165" align="center" nowrap><?php require_once 'include/miniCart.php'; ?></td>
</tr>
</table>
<?php
require_once 'include/footer.php';
?>[/code]

Any suggestions would be appreciated. Thanks for all the help.
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142986
Share on other sites

you still need the session_start() before anything else

[code]
<?php

session_start();

require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';
?>
<head>
<style type="text/css">
.style1 {
font-family: "Bauhaus 93";
}
.style4 {
font-size: xx-large;
}
</style>
</head>

<?php

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId  = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

require_once 'include/header.php';
ob_end_flush();
?>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%">
  <tr valign="top">
  <td width="164" valign="top" height="100%" background="images/index1_55.jpg"  id="leftnav">
<?php
require_once 'include/leftNav.php';
?>
  </td>
  <td>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr>
                <td width="100%" valign="top">
                  <p align="center" class="style1">&nbsp;Current Deals</td>
              </tr>
              </table>
<?php
if ($pdId)
{
require_once 'include/productDetail.php';
}
else if ($catId)
{
require_once 'include/productList.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return')
{
require_once 'include/return_policy.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='shipping')
{
require_once 'include/shipping.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_warranties')
{
require_once 'include/m_worranties.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='contact_us')
{
require_once 'include/contact_us.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return_request')
{
require_once 'include/return_request.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='website_issue')
{
require_once 'include/website_issue.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='feedback')
{
require_once 'include/feedback.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_website')
{
require_once 'include/m_website.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='about_us')
{
require_once 'include/about_us.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='privacy_policy')
{
require_once 'include/privacy_policy.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='aggrement')
{
require_once 'include/aggrement.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='search')
{
require_once 'include/search.php';
}
else
{
require_once 'include/categoryList.php';
}

?> 
  </td>
  <td  background="images/index1_55.jpg" width="165" align="center" nowrap><?php require_once 'include/miniCart.php'; ?></td>
</tr>
</table>
<?php
require_once 'include/footer.php';
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142989
Share on other sites

No, the session_start() function is inside the config.php included file. That is obvious from the error the OP posted earlier:
[quote]Notice: A session had already been started - ignoring session_start() in /vservers/shopmemo/htdocs/library/config.php on line 11[/quote]

Ken
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142991
Share on other sites

I checked and there is nothing before the <?php. So I don't need the session_start() after the <?php? I took that out and I get the previous error again.

[code]Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11[/code]

Here is what the code looks like on my end.

[code]<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';
?>
<head>
<style type="text/css">
.style1 {
font-family: "Bauhaus 93";
}
.style4 {
font-size: xx-large;
}
</style>
</head>

<?php

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId  = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

require_once 'include/header.php';
ob_end_flush();
?>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%">
  <tr valign="top">
  <td width="164" valign="top" height="100%" background="images/index1_55.jpg"  id="leftnav">
<?php
require_once 'include/leftNav.php';
?>
  </td>
  <td>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr>
                <td width="100%" valign="top">
                  <p align="center" class="style1">&nbsp;Current Deals</td>
              </tr>
              </table>
<?php
if ($pdId)
{
require_once 'include/productDetail.php';
}
else if ($catId)
{
require_once 'include/productList.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return')
{
require_once 'include/return_policy.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='shipping')
{
require_once 'include/shipping.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_warranties')
{
require_once 'include/m_worranties.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='contact_us')
{
require_once 'include/contact_us.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return_request')
{
require_once 'include/return_request.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='website_issue')
{
require_once 'include/website_issue.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='feedback')
{
require_once 'include/feedback.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_website')
{
require_once 'include/m_website.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='about_us')
{
require_once 'include/about_us.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='privacy_policy')
{
require_once 'include/privacy_policy.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='aggrement')
{
require_once 'include/aggrement.php';
}
elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='search')
{
require_once 'include/search.php';
}
else
{
require_once 'include/categoryList.php';
}

?> 
  </td>
  <td  background="images/index1_55.jpg" width="165" align="center" nowrap><?php require_once 'include/miniCart.php'; ?></td>
</tr>
</table>
<?php
require_once 'include/footer.php';
?>[/code]

Thanks again for all the help. Any suggestions would be appreciated.
Link to comment
https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142995
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.