The only rule is that you need to call session_start() before any output
is sent to the browser.
You can accomplish this by either making sure that your script won't
echo/print any data (and won't print notices, warnings, etc) before
session_start() is called, or you can turn on output buffering (so make
your first line ob_start(), or set it up via configs), so all output is
buffered on the server until the script completes.
Ben Sgro wrote:
Hello all,
I have a class that handles session and that is included further down
in the class.
Typically file struct:
PHP
Config (dev, live, etc)
Includes
Instantiate classes (session_start( ) gets called in the session
objects constructor)
Support functions
Main code, usually in the form of a switch( ) on a GET/POST var
Debug data (db/script execution time, etc.)
</PHP
Works great for me.
- Ben
David Krings wrote:
chad qian wrote:
Hi,
I try to debug one php page.Everything is fine but I always get this
error message on top when I load the web page:
*Warning*: session_start() [_function.session-start_
<http://chad.geta2q.com/function.session-start>]: Cannot send
session cache limiter - headers already sent (output started at
/home/getatwoq/public_html/chad/registrationverified.php:3) in
*/home/getatwoq/public_html/chad/inc/prehtml.php* on line *23*
** I want to get rid of this meaage when I locad the php web page.
How to do it?
I found that session_start() works only OK when it is the first thing
that happens in a script. Before initializing variables and anything.
You script should start as such
<?php // Line 1
session_strt(); // Line 2
....everything else
I follow that strictly and since then never had a problem.
David
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php