KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Retrieving the browser's IP address with the setup of 4D, 4D Link and 4D WebSTAR
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: November 15, 2002

Compatibility, 4D: Versions 6.7.x and 6.8.x
Compatibility, 4D WebSTAR: WebSTAR version: 5.x

When using 4D's native built-in Web server, $3 returns the browser's IP address. Using 4D in conjunction with 4D Link and 4D WebSTAR, $3 will always return the IP address of the 4D WebSTAR machine. If you need the original browser's IP address, this can still be extracted using the command:

GET HTTP HEADER (header|fieldArray{; valueArray})

The command GET HTTP HEADER returns either a string or two arrays, containing the HTTP header used for the currently processed request.

Using the arrays approach, the header for the original browser's IP address is "X-Orig-IP" returned in the 10th element.

Thus, to get the browser IP you would simply do this:

ARRAY TEXT(a_header;0)
ARRAY TEXT(valuearray;0)
GET HTTP HEADER(a_header;valuearray)
$BrowserIP:=valueArray{10}