Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session question

Status
Not open for further replies.

richardko

Programmer
Jun 20, 2006
127
US
Hi,
I have a system where i am trying to pass session between two files.
There is a file called "editor.php" and there is a file called "index.php"

when i am in "editor.php" i set certain session variables. Within that "editor.php" i call php's "file" command like this:
Code:
$fh = file("index.php");
while($fh as $line)
{
}
but the session does not pass to "index.php" since i am calling a file handler and not doing a HTTP request...is there a way around it or change it so that I can pass session variables to "index.php"?

thanks
ro
 
a number of ways.

you could use cUrl to access the file
you could append the session to the filename as a query string and open the file using a http:// address rather than a file://

in any event. if you open a file using the file protocol it will not be evaluated by php. you will be getting the php code. http will avoid this behaviour. you could also use include instead.

Code:
$file = "file.php";
ob_start();
include $file;
$fileContents = ob_get_contents();
ob_end_clean();
 
thank you for the update. I have resolved the issue for now but i will keep your answer in mind for future references.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top