How do i get user mac address?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kennedysee
Forum Newbie
Posts: 14
Joined: Fri Dec 04, 2009 12:17 am

How do i get user mac address?

Post by kennedysee »

How do i detect the user mac address when they visit the website?

Somehow i manage to detect the pc that is running apache, but not from another computer. It keep prompting the same mac address....
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How do i get user mac address?

Post by pickle »

The MAC address isn't passed on any layer PHP can access.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
eFishy
Forum Newbie
Posts: 9
Joined: Tue Jan 05, 2010 12:26 pm

Re: How do i get user mac address?

Post by eFishy »

If the user is a host on the same local network you could use the arp cache to find the mac using the IP address you can get in PHP.
Although if there is a layer3 device such as a router between you and the client this wouldn't work, instead you would be returned the MAC of the routing device.
kennedysee
Forum Newbie
Posts: 14
Joined: Fri Dec 04, 2009 12:17 am

Re: How do i get user mac address?

Post by kennedysee »

pickle wrote:The MAC address isn't passed on any layer PHP can access.
Then in what other language can i retrieve for MAC address?


<?php
function getMac(){
exec("ipconfig /all", $output);
foreach($output as $line){
if (preg_match("/(.*)Physical Address(.*)/", $line)){
$mac = $line;
$mac = str_replace("Physical Address. . . . . . . . . :","",$mac);
}
}
return $mac;
}

$mac = getMac();
$mac = trim($mac);
?>
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: How do i get user mac address?

Post by manojsemwal1 »

good function i read it knowledgeable article.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: How do i get user mac address?

Post by Apollo »

kennedysee wrote:Then in what other language can i retrieve for MAC address?
Note that the getMac() function above gets the mac address of the server, not the visitor :) (and only if the host is a windows machine)
kennedysee
Forum Newbie
Posts: 14
Joined: Fri Dec 04, 2009 12:17 am

Re: How do i get user mac address?

Post by kennedysee »

Apollo wrote:
kennedysee wrote:Then in what other language can i retrieve for MAC address?
Note that the getMac() function above gets the mac address of the server, not the visitor :) (and only if the host is a windows machine)

how do i get the visitor mac address?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How do i get user mac address?

Post by pickle »

You can't.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
kennedysee
Forum Newbie
Posts: 14
Joined: Fri Dec 04, 2009 12:17 am

Re: How do i get user mac address?

Post by kennedysee »

pickle wrote:You can't.
Any other way?
Post Reply