is there a way to pass php variables to pages? (such as IP address of user)…
No, but you can use PHP Server Variables with Show If design areas (and Paint Layout conditions). What are you trying to achieve?
I am using a remote content page to 'interface' a search directory. but this directory returns customised results based on the IP address range of the user.
This is pretty much on the same topic…
I am needing to get the user IP in to a page so I created a php page with the following:
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ip = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip = getenv(REMOTE_ADDR);
}When viewing the php page at its actual path, I get my correct, remote IP address.
But, when using a Remote Content page I get my local IP address, which is strange. I need to be getting the remote IP, not the local. Why would it get the remote when not using remote content, but local when using remote content?
Because Remote Content turns the web server into a browser. The "client" in this case is the Matrix PHP process running on the webserver. So, you'll always get the server's IP address. You may need to use an iframe to grab the actual remote user's IP address, or create a custom asset to do it.
Avi is right as to the reason. With remote content the web server makes teh request not the user.
In 3.18.7 you can use %globals_server_XXX% keywords to access the apache environment values, including the remote IP.