3

I want to find the MAC address of my client, for my website based on PHP. Currently I am using the code provided to fetch the mac address on a linux OS. I want to know will this method work on any linux distro , and if not, then how can I fetch the MAC address for any OS. Also is there anything that works on any OS, wether linux or windows or mac.

$mac_linux = shell_exec('cat /sys/class/net/*/address');
$mac = trim($mac_linux); 
$data   = preg_split('/\s+/', $mac);
$mac1 = $data[0];
$mac2 = $data[1];
$mac3 = $data[2];

1 Answers1

2

You can't access your client's MAC address. The thing you are trying to do with the code above will get you your own machine's MAC address. You can refer to this question and find the detailed answer.

TamirNahum
  • 484
  • 2
  • 8
  • OK. Thank You. How do websites create log of users for any database changes without their mac? I wanted to store client's mac address everytime he/she updates his/her profile. – Abhishek Rautela Mar 09 '20 at 06:29
  • You can do it by saving their `IP address`. Usually this kind of logs are saved with a foreign key that references to the actioning account, action description and IP address. – TamirNahum Mar 09 '20 at 06:35