session variables in OOP....
| From: | Wilbert Enserink | Date: | Fri, 14 Jun 2002 11:44:01 +0000 |
| Subject: | session variables in OOP.... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-102202@lists.php.net to get a copy of this message | ||
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
----class.basebape.php---------------
<?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
-------------------------------
---------------main.php----------
echo "a lot of HTML depending on queries and stuff";
session_register($variable);
------------------------------------
------------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
http://www.pdd.nl
info@pdd.nl
-------------------------