Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anuragpetkar's avatar

how can i get machine ip

I want to store separate address if user is in same network

0 likes
6 replies
cmdobueno's avatar

You cant, at least not that I have seen. Nor have I ever found a good reason to gather that info... it provides inconsistent and overlapping data, but it is not my project/code. Do as you please... I am only going to suggest you really think about your "End Goal" and possibly find a better solution (post your reason... I am curious as to why you want local IP's)

1 like
anuragpetkar's avatar

@cmdobueno I just want to track how many user visit my website in a day if 100 user in same lan i will get only one user as unique ip if i use $_SERVER['REMOTE_ADDR']

cmdobueno's avatar

Correct, tracking in that way is generally extremely hard.

Generally speaking, tracking like that is hard in general. Sometimes it is best to generate a token for the browser, which I will not go into details on (I personally have no done that... so I cant help with how to do it)... I just know there is a way to create a "finger" print with the browser... it is not perfect, and you can easily "trick" the system into allowing the total views/visitors to go up... but that is life...

Cronix's avatar

Just use google analytics or something. They do it better than you can anyway.

2 likes
cmdobueno's avatar

Amen to that. Trying to track unique visitors is not as simple as people make it out to be...

Please or to participate in this conversation.