LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 06: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, 07: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, 07: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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:57 AM.

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
Open Source Consulting | Domain Registration