0

I'm creating php examination project in which requirement is that every user can give exam only once, for that i am checking ip address of user for uniqueness. I'm using this javascript for fetching ip address

$.get("https://ipinfo.io/", function(response) {

}, "jsonp");

but in it all devices connected in one wi-fi network returning same ip address which is problematic, is there any other option available to get each device's ip address uniquely even though they're connected on same network. mac address isn't the solution for me in here.

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Parth Goswami
  • 323
  • 4
  • 16
  • 2
    Do your users login? – RiggsFolly Jan 11 '17 at 11:07
  • Only login functionality can save you then – Alive to die - Anant Jan 11 '17 at 11:07
  • @Anant yeah i'm having register functionality but it's optional as that's how client wants it to be, so that won't help me if user skip the registration – Parth Goswami Jan 11 '17 at 11:11
  • 3
    Only login would be waterproof, but you could try using cookies as a solution. Of course, if the user removes or edits their cookies you're doomed, it should be a last resort. – Ramon Jan 11 '17 at 11:12
  • Sorry mate you can't without login – Alive to die - Anant Jan 11 '17 at 11:14
  • generate some random values for all users and save then into database – prakash tank Jan 11 '17 at 11:14
  • Try `var_dump($_SERVER);` to see if all of those clients have same or different IP address by checking the value of `REMOTE_ADDR` or if proxy is set, you can check the value of `HTTP_X_FORWARDED_FOR`. As you said maybe user skips registration, this checking in PHP is only way to solve your issue if you're not going for login functionality. – Wolverine Jan 11 '17 at 11:16
  • @Perumal93 what it will return? client ip address or the server ip address? I required client ip for this – Parth Goswami Jan 11 '17 at 11:22
  • This will be an interesting thing for you http://samy.pl/evercookie/, although its also not 100% – Sunil Verma Jan 11 '17 at 11:23
  • you can use '$_SERVER['REMOTE_ADDR'] ' to get client IP in php, but even user can bypass this, so best way to get users registered before they start the test and if not possible simply get their IP and store it in DB and next time, check from DB – Bilal Zafar Jan 11 '17 at 11:24
  • @SunilVerma what if client uses different browser to appear for the test,then this approach wouldn't work, will it? Though thanks for suggestion will try it – Parth Goswami Jan 11 '17 at 11:26
  • @ParthGoswami another best way is to take user's cell number and send a verification code on their mobile and by verifying that code they will be able to start the quiz. on the other hand, if user tries to take test second time you can easily match their cell number. – Bilal Zafar Jan 11 '17 at 11:31
  • Also you might want to loook at http://stackoverflow.com/questions/5074139/how-to-get-mac-address-of-client-using-php although its unreliable due to involvement of client side programming, so best will be somehow use DB – Sunil Verma Jan 11 '17 at 11:31
  • @ParthGoswami Sorry about the late reply. It returns client's IP address. For your information, `SERVER_ADDR` returns IP address of the server you host your project on. `REMOTE_ADDR` returns the IP address of a client. In case, proxy server is used for those clients, you will need to use `HTTP_X_FORWARDED_FOR` rather than using `REMOTE_ADDR`. Hope you got it. – Wolverine Jan 11 '17 at 13:45

0 Answers0