just convert the variable to the session variable that you want to use in another php file.
For example, if I created a login page in which I define the username as a variable that will be the same throughout the session. so i will write here
$_SESSION['username']=$username;
and use in another php file as you want to display this variable use
echo '$_SESSION['username']';
source share