This topic is locked

session variables not passing to external files

6/12/2014 4:29:35 PM
PHPRunner General questions
W
wfcentral author

I used this code in some phprunner 6 projects and it worked great - placed it in some external files I wanted to protect.
session_start();

if(!@$_SESSION["UserID"])

{

header("Location: login.php?message=expired");

return;

}
I put the same code in a new version 7 project (in the external files) and when I call the page from my phprunner 7.1 generated project it does not see the session values. They are always blank.
I even tried added this in the phprunner page to see if the value is loading - echo $_SESSION['userID'] (works fine)

and then placed same code in an external file and it shows nothing.
So, why are the session values not passing from one page to the other??

W
wpl 6/13/2014

wfcentral,
this is caused by the following code in dbcommon.php:



@session_name(str_replace(" ", "", "s##@BUILDER.m_lastDbSyncTime##"));

@session_start();


which translates into e.g.:



@session_name(str_replace(" ", "", "s1402464460"));


This was introduced with Version 7.x to avoid confusion with session vars between different Apps on the same server,

run by the same user. I think since you do not know the generated session name, you cannot join this session.

J
jmclain 6/13/2014

Maybe you have already done this but starting with ver 7 for any external or custom files I need to include the following in order to use PHPR session values. . .

include('include/dbcommon.php');
Sergey Kornilov admin 6/13/2014

+1 to what both wpl and DIE_HARD say.