-2

I tired so many solutions but nothing worked, I tried using clients mac address as unique device id for the user then checking once logging process started that this mac address is allowed mac address stored in then database. this was the code :

$MAC = exec('getmac');

// Storing 'getmac' value in $MAC
$MAC = strtok($MAC, ' ');

 // Updating $MAC value using strtok function, 
// strtok is used to split the string into tokens
// split character of strtok is defined as a space
// because getmac returns transport name after
// MAC address   
echo "MAC address of client is: $MAC";

But this code always returns server mac address

Yash Chitroda
  • 645
  • 4
  • 8
  • 27
  • 2
    Does this answer your question? [How to prevent multiple logins in PHP website](https://stackoverflow.com/questions/1727919/how-to-prevent-multiple-logins-in-php-website) – Wahyu Kristianto Sep 04 '21 at 08:22
  • `$MAC = exec('getmac');` You run that command on the server, what did you expect? – brombeer Sep 04 '21 at 08:23
  • @WahyuKristianto that question did not help me because I want to check if user is allowed to login website from this computer and if allowed then go to the dashboard if not display a message **you cannot login this device** – Qarni Technology Sep 04 '21 at 08:30
  • 1
    Authentication and Authorisation are not the same thing. Before you can authorise someone to access parts of your website they will have to identify themselves, ie: Authentication. This is usually done via some sort of sign in method. There are plenty of tutorials and frameworks out there that accomplish this, like Laravel. If you want to block anyone that is not authenticated from accessing your domain completely the easiest way to accomplish this is IP Address white listing. SO is not a tutorial website, so have a go at google. Just FYI there are no easy solutions to your question. – Erik Sep 04 '21 at 08:38
  • @QarniTechnology Let me clarify. You have saved your client's mac address before. Then you will use this code to check if the mac from the client is in your database? – Wahyu Kristianto Sep 04 '21 at 08:46
  • @WahyuKristianto yeah man we're on same way now, that is exactly what i searching for do you have any solution for it? – Qarni Technology Sep 04 '21 at 10:35
  • FYI https://stackoverflow.com/a/5074163/984422. Also https://stackoverflow.com/a/1420402/984422. – Wahyu Kristianto Sep 04 '21 at 12:27
  • Does this answer your question? [How to get MAC address of client using PHP?](https://stackoverflow.com/questions/5074139/how-to-get-mac-address-of-client-using-php) – Nico Haase Sep 06 '21 at 10:13
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 08 '21 at 09:25

1 Answers1

0

getmac is used to determine the MAC address of the local machine.

You can not determine the MAC address of an IP peer, with the possible exception of peers on the local physical segment through ARP caching.

I suggest you reconsider your approach.

David Jones
  • 2,879
  • 2
  • 18
  • 23