How can I get the MAC and the IP address of a connected client in PHP?

前端 未结 16 2383
长发绾君心
长发绾君心 2020-11-22 02:29

I need to know the MAC and the IP address of the connect clients, how can I do this in PHP?

16条回答
  •  被撕碎了的回忆
    2020-11-22 03:09

    The MAC address of a client (in the sense of the computer that issued the HTTP request) is overwritten by every router between the client and the server.

    Client IP is conveniently provided to the script in $_SERVER['REMOTE_ADDR']. In some scenarios, particularly if your web server is behind a proxy (i.e. a caching proxy) $_SERVER['REMOTE ADDR'] will return the IP of the proxy, and there will be an extra value, often $_SERVER['HTTP_X_FORWARDED_FOR'], that contains the IP of the original request client.

    Sometimes, particularly when you're dealing with an anonymizing proxy that you don't control, the proxy won't return the real IP address, and all you can hope for is the IP address of the proxy.

提交回复
热议问题