Jump to content

$_server['remote_addr'] In "included" Php Page


smerny

Recommended Posts

I wanted to use $_SERVER['REMOTE_ADDR'] in a page that is included in another page.... and it just gives me the IP of the webhost... how can I get around that without having to add to every page that includes this one?

Link to comment
Share on other sites

http://php.net/manual/en/reserved.variables.server.php 'HTTP_HOST' Contents of the Host: header from the current request, if there is one. 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
Link to comment
Share on other sites

'REMOTE_ADDR' The IP address from which the user is viewing the current page.That is what I want by it's description

Link to comment
Share on other sites

I had the same problem with session variables.... how can I do a file include if say i want /folder1/file1.php to include /folder2/file2.php and be able to use session variables or $_SERVER['REMOTE_ADDR']?

Link to comment
Share on other sites

Just don't include files using HTTP. If all the files are on the same server, use the regular file path to include them instead of HTTP, that's the normal way to include a file anyway. You're sort of breaking file includes if you use HTTP to include them. You should only use HTTP if you're trying to include a file on another server, and even then another way might be better.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...