php include files
Hi.
I have 2 php files - one included within the other. info2.php --------------------------------------------------------- <?php session_start(); include ($DOCUMENT_ROOT . "/info.php"); ?> --------------------------------------------------------- and : info.php --------------------------------------------------------- <?php session_start(); $count = $_SESSION['count'] + 1; echo "%%%" . $count . "%%%" ; $_SESSION['count'] = $count; ?> --------------------------------------------------------- If I take out the $DOCUMENT_ROOT in the include statement the session variable persists and is incremented.In other words the include file is referenced relatively. If howerver the file is referenced absolutely like in the example above the session variable $_SESSION['count'] is either lost or reinitialized. Could anybody help.... |
I don't know why you see this difference in behavior but I don't think you should be calling session_start twice.
|
Thanksforthereply.
I am not too worried about the session start, but will take it out anyway.It basically comes down to whether I call the include with a absolute url or a relative one. absolute : include "http://www.blah.com/info.php. relative : include "info.php" Here is another thing.I check the session file directory and when I use absolute reference a new session file is created everytime I refresh! On the other hand with relative reference it does not. I have to go read how the php include mechanism works..... |
All times are GMT -5. The time now is 01:15 PM. |