note 26372 modified in function.session-start by philip

From: Date: Fri, 13 Dec 2002 18:07:01 +0000
Subject: note 26372 modified in function.session-start by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-40871@lists.php.net to get a copy of this message
I would just like to say: 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... I've been frustrated by this so many times it's not funny. Use: <?php session_start(); include 'inc/config.inc.php'; include 'inc/common.inc.php'; /* Page code */ ?> Not: <?php include 'inc/config.inc.php'; include 'inc/common.inc.php'; session_start(); /* Page code */ ?> This is important because including a file is _exactly_ like pasting it into the page, just cleaner. If you don't call the session _first_, the config code won't recognize it and you will waste a lot of time and be really annoyed. --was-- I would just like to say: 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... I've been frustrated by this so many times it's not funny. Use: <?php session_start(); include 'inc/config.inc.php'; include 'inc/common.inc.php'; /* Page code */ ?> Not: <?php include 'inc/config.inc.php'; include 'inc/common.inc.php'; session_start(); /* Page code */ ?> This is important because including a file is _exactly_ like pasting it into the page, just cleaner. If you don't call the session _first_, the config code won't recognize it and you will waste a lot of time and be really annoyed. Luck Everyone! ~ Shadowflame http://www.starpilot.net http://www.php.net/manual/en/function.session-start.php

« previous php.notes (#40871) next »