Passing sessions problem [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

oops, that was stupid of me.
revised version:

Code: Select all

echo '<div>Debug File: "', __FILE__, '@', __LINE__, "\"</div>\n";
echo '<pre>Debug call stack: '; var_dump(debug_backtrace()); echo "</pre>\n";
echo '<pre>Debug _SESSION: '; var_dump($_SESSION); echo"</pre>\n";

$url = $_SESSION['url'];
lyleyboy
Forum Commoner
Posts: 27
Joined: Sat Mar 18, 2006 5:05 am
Location: Birmingham, UK

Post by lyleyboy »

4
Debug query: "SELECT * FROM script_list WHERE id='4'"
Debug url: "http://www.flittermouse.com/scripts/free/javadd"
session: "http://www.flittermouse.com/scripts/free/javadd"
Debug File: "/homepages/8/d92992469/htdocs/Flittermouse/includes/nav_free.php@2"

Debug call stack: array(0) {
}

Debug _SESSION: NULL
Warning: (null)() [function.mysql-free-result]: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

oh, nav_free.php
$File = "http://www.flittermouse.com/includes/nav_free.php";
$fh = fopen($File, 'r');
What happens here?
php sends a new http request for /includes/nav_free.php to http://www.flittermouse.com
The server at http://www.flittermouse.com starts a new instance of php. This new instance executes nav_free.php
The output of that php instance is sent back to the php instance with the fopen($File, 'r') code.
Both php instances are not connected to each other - even if they run on the same server. You can see "evidence" of that in the missing call stack
Debug call stack: array(0) {
}
session_start() has to be called for each instance of php that is supposed to access session data.

Why do you request the file include/nav_free.php via http? I thought both files are located at the same server?
lyleyboy
Forum Commoner
Posts: 27
Joined: Sat Mar 18, 2006 5:05 am
Location: Birmingham, UK

Post by lyleyboy »

That line is one of my attempts to make it work.

I was trying to read the file into a var rather than using an include to see if that fixed the problem.

I did have the session_start() in the nav_free page but it made no difference.

I am calling things via http because I am trying to make to script easier to maintain and there are lots of pages in a lot of folders. I thought going global would make it easier.

So where do i go from here? All I really want is to pass the $url pulled from the db to the nav_free page where it can then be used to build the urls for the nav page.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

lyleyboy wrote:So where do i go from here? All I really want is to pass the $url pulled from the db to the nav_free page where it can then be used to build the urls for the nav page.
Then you do not need a session at all.
Pull the data from the database, then include the other script (without http://)


First step:
replace
//Include the navigation pane.
//include('http://www.flittermouse.com/includes/nav_free.php');
$File = "http://www.flittermouse.com/includes/nav_free.php";
$fh = fopen($File, 'r');
$nav = fread($fh, 10000);
fclose($fh);
echo $nav;
by

Code: Select all

die('<div>cwd: ' . getcwd() .  '</div>');
// require 'includes/nav_free.php';
lyleyboy
Forum Commoner
Posts: 27
Joined: Sat Mar 18, 2006 5:05 am
Location: Birmingham, UK

JOB DONE

Post by lyleyboy »

Thanks for your help.
And the answer was quite simple. all i did was include by ../../ rather than http
Post Reply