You are here: Re: [PHP] include file and problems with headers « PHP « IT news, forums, messages
Re: [PHP] include file and problems with headers

Posted by Brian V Bonini on 05/27/05 04:23

On Sat, 2005-05-21 at 06:30, Ross wrote:
> I have the folowing code which checks whether the user has logged in.
>
> if (!isset ($_SESSION['new_session'] ) )
> {
>
> $login_status = "<div class=\"standard_text\">Your are not signed in
> </div>";
>
> }
> if (isset ($_SESSION['new_session'] ) )
> {
> $address = $_SESSION['new_session'];
> $login_status = "<div class=\"standard_text\">Your are signed in as <span
> class=\"under\">$address</span></div>";
> }
> ?>
>
>
> Now when I have this as a file to be included in each page, status.php (see
> code) gives the header error (already sent).
>
> <?php
> session_start();
> include('status.php');

How about putting session_start in status.php then just include it.

<?php

session_start();

if (!isset ($_SESSION['new_session'] ) )
{

$login_status = "<div class=\"standard_text\">Your are not signed in
</div>";

}
if (isset ($_SESSION['new_session'] ) )
{
$address = $_SESSION['new_session'];
$login_status = "<div class=\"standard_text\">Your are signed in as <span
class=\"under\">$address</span></div>";
}

echo $login_status;

?>

Then in other files just:

<?php include 'status.php'; ?>

--

s/:-[(/]/:-)/g


Brian GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация