If you want to do it right, don' t output anything, obviously. Instead of
using ECHO, assign all output to a variable within your class. Then, at the
end of the processing, after everything is done, echo out that variable
(which will contain the entire page). Then you can set cookies, sessions,
whatever, at any point.

Or you can use output buffering...

---John Holmes...

----- Original Message -----
From: "Wilbert Enserink" <[EMAIL PROTECTED]>
Sent: Friday, June 14, 2002 7:44 AM
Subject: [PHP] session variables in OOP....

Hi all,

I'm busy building a site which uses OOP.
Several classes are used to constuct different sections of the final page to
be displayed.
The overall class is called class.basepage.php
This is the page which outputs HTML and calls other classes to construct
other parts of the page.
Now I have this problem: In one of the objects I use session variables.
However i get the famous error :....Cannot send session cookie - headers
already sent by (output started ................"

Is there a way to overcome this problem? I mean: the session variable is
registered in the main part of the page after the class $this->header is
called (which writes HTML)... now, I don't think I can register the
sessionvariable at the top of my script since the value of the session var
is determined in the main.class.......or can I?

I hope you understand my problem and have some tips for me. Below is some
code snippets I'm using:

thx and regards

Wilbert Enserink

  <?php $this->header(); ?>// includes a php file which writes HTMLcode
functioning as the "header" of the HTML page (i.e. navigation menu)
 <?php $this->main(); ?> // includes a php file (main.php) which writes the
main part of the HTML data

echo "a lot of HTML depending on queries and stuff";

------------output browser----------
Warning: Cannot send session cookie - headers already sent by (output
started at
/opt/guide/www.designmatcher.com/HTML/wwwtest/class.basepage.php:125) in
/opt/guide/www.abc.com/HTML/wwwtest/phpincludes/main/main.php on line 400

Pas de Deux
Van Mierisstraat 25
2526 NM Den Haag
tel 070 4450855
fax 070 4450852

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to