Advice on IP capture
-
Advice on IP capture
I currently use cloudflare as a CDN, I found that this plugin only captures the visitor’s cloudflare proxy IP, not the visitor’s real IP, I checked the plugin code and found that it is only from the fileclass-sfa-abandoned-carts-recorder.php
the code$_SERVER['REMOTE_ADDR']
Get the IP, but in the case of using CDN, the cloudflare CDN IP is recorded,
So I suggest modifying the logic of obtaining the IP address in order to obtain the real IP of the visitor.
I currently put the code'ip_address' => $_SERVER['REMOTE_ADDR']
changed to'ip_address' => $_SERVER["HTTP_CF_CONNECTING_IP"] ?? $_SERVER['REMOTE_ADDR']
At present, the real IP of the visitor can be obtained normally when using cloudflare CDN.
- The topic ‘Advice on IP capture’ is closed to new replies.