Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 990457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:57:01+00:00 2026-05-16T05:57:01+00:00

Here is the web structure of my page: 01.<?php // rnlogout.php 02.include_once ‘rnheader.php’; 03.echo

  • 0

Here is the web structure of my page:

01.<?php // rnlogout.php
02.include_once 'rnheader.php';
03.echo "<h3>Log out</h3>";
04. 
05.if (isset($_SESSION['user']))
06.{
07.    destroySession(); // report error here!!!!!!
08.    echo "You have been logged out. Please
09.    <a href='index.php'>click here</a> to refresh the screen.";
10.}
11.else echo "You are not logged in";
12.?>

function destroySession()
{
    $_SESSION=array();

    if (session_id() != "" || isset($_COOKIE[session_name()]))
        setcookie(session_name(), '', time()-2592000, '/');

    session_destroy();
}

01.<?php // rnheader.php
02.include 'rnfunctions.php';
03.session_start();
04. 
05.if (isset($_SESSION['user']))
06.{
07.    $user = $_SESSION['user'];
08.    $loggedin = TRUE;
09.}
10.else $loggedin = FALSE;
11. 
12.echo "<html><head><title>$appname";
13.if ($loggedin) echo " ($user)";
14. 
15.echo "</title></head><body><font face='verdana' size='2'>"; // called first!!!!!
16.echo "<h2>$appname</h2>";
17. 
18.if ($loggedin)
19.{
20.    echo "<b>$user</b>:
21.         <a href='rnmembers.php?view=$user'>Home</a> |
22.         <a href='rnmembers.php'>Members</a> |
23.         <a href='rnfriends.php'>Friends</a> |
24.         <a href='rnmessages.php'>Messages</a> |
25.         <a href='rnprofile.php'>Profile</a> |
26.         <a href='rnlogout.php'>Log out</a>";
27.}
28.else
29.{
30.    echo "<a href='index.php'>Home</a> |
31.         <a href='rnsignup.php'>Sign up</a> |
32.         <a href='rnlogin.php'>Log in</a>";
33.}
34.?>

Please take a look the line 07

destroySession(); // report error here

Based on the php manual, http://us2.php.net/setcookie
cookies must be sent before any output from your script. Here the rnheader.php
call echo even before the setcookie call in function destroySession.

So how do I change the page structure to fix this problem?

The error message is as follows:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LPMJ_examples\robinsnest\rnheader.php:12) in C:\xampp\htdocs\LPMJ_examples\robinsnest\rnfunctions.php on line 41

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:57:02+00:00Added an answer on May 16, 2026 at 5:57 am

    read the PHP-Manual :: Output Control

    if you don’t want to rewrite your scripts use output control functions (as mention above)

    <?php
    ob_start();
    include_once 'rmheader.php';
    echo '<h3>Log Out</h3>';
    
    if (isset($_SESSION['user'])) {
        destroySession(); // report error here!!!!!!
        echo "You have been logged out. Please <a href='index.php'>click here</a> to refresh the screen.";
    } else {
        echo "You are not logged in";
    }
    
    function destroySession()
    {
        $_SESSION=array();
    
        if (session_id() != "" || isset($_COOKIE[session_name()]))
            setcookie(session_name(), '', time()-2592000, '/');
    
        session_destroy();
    }
    
    ob_end_flush();
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.