LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



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

Rep: Reputation: 15
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....
 
Old 10-27-2003, 08:39 AM   #2
tgflynn
Member
 
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, 08:54 AM   #3
abrb220
Member
 
Registered: Jul 2003
Location: Roodepoort South Africa
Distribution: Redhat / Suse
Posts: 39

Original Poster
Rep: Reputation: 15
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.....
 
  


Reply


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-06-2005 12:07 AM
PHP include() not working kodon Slackware 13 08-10-2004 07:05 AM
php include msound Programming 2 06-24-2004 05:21 PM
PHP Path include ..:eMa:.. Programming 4 09-25-2003 02:59 AM
php - include, require and arrays gui10 Programming 1 02-05-2002 09:54 AM


All times are GMT -5. The time now is 01:42 PM.

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