note 27946 deleted from function.session-start by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Fri, 27 Dec 2002 04:42:26 +0000 |
| Subject: | note 27946 deleted from function.session-start by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-41330@lists.php.net to get a copy of this message | ||
As per <shadowflame at starpilot dot net>:
"If you are using an include page, such as a config or possibly common-functions page, that
relies on session variables being pulled from the sesssion, remember to add the session_start()
function _before_ you call the includes, or your session will not be called by the page..."
Any include or require called before you call session_start() will cause the initial session setup
to fail, even if that include file contains only a comment!
Here are scenarios:
include("blank_file.php");
session_start();
This works. However:
include("file_with_just_a_comment_in_it.php");
session_start();
Does not.
The recommended way to use session_start() is of course to put it at the top of the page. However,
if, like me, you find yourself wanting to start a session only as a result of some previous logic,
this avenue is closed to you. You will have to use ob_start() and related functions, and create a
code mess.
It will be a beautiful day when header conflicts are caused only by the layout of my code rather
than PHP code cruft.