Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-27-2003, 06:27 AM   #1
Registered: Jul 2003
Location: Roodepoort South Africa
Distribution: Redhat / Suse
Posts: 39

Rep: Reputation: 15
php include files


I have 2 php files - one included within the other.



include ($DOCUMENT_ROOT . "/info.php");


and :



$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
is either lost or reinitialized.

Could anybody help....
Old 10-27-2003, 07:39 AM   #2
Registered: Oct 2003
Location: Rochester, New York (USA)
Distribution: Debian
Posts: 119

Rep: Reputation: 15
I don't know why you see this difference in behavior but I don't think you should be calling session_start twice.
Old 10-27-2003, 07:54 AM   #3
Registered: Jul 2003
Location: Roodepoort South Africa
Distribution: Redhat / Suse
Posts: 39

Original Poster
Rep: Reputation: 15

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 "
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.....


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP include it-s Programming 3 10-05-2005 11:07 PM
PHP include() not working kodon Slackware 13 08-10-2004 06:05 AM
php include msound Programming 2 06-24-2004 04:21 PM
PHP Path include ..:eMa:.. Programming 4 09-25-2003 01:59 AM
php - include, require and arrays gui10 Programming 1 02-05-2002 08:54 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration