note 27946 added to function.session-start

From: Date: Fri, 27 Dec 2002 01:34:34 +0000
Subject: note 27946 added to function.session-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-41324@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. -- http://www.php.net/manual/en/function.session-start.php http://master.php.net/manage/user-notes.php?action=edit+27946 http://master.php.net/manage/user-notes.php?action=delete+27946 http://master.php.net/manage/user-notes.php?action=reject+27946

« previous php.notes (#41324) next »