I am using php and I want to get a System's UNIQUE ID.
I can't use $_SERVER['REMOTE_ADDR']
since all machines have the same local IP address (127.0.0.1). Is there anything else I could use?
Asked
Active
Viewed 352 times
0

cyfur01
- 3,262
- 1
- 34
- 38

Ender Graphix
- 47
- 2
- 6
-
1See: http://stackoverflow.com/q/1846202/3933332 – Rizier123 Jul 20 '15 at 00:01
-
3depends on what your call a "system" there are a number of possible id's depending on usage also – Jul 20 '15 at 00:04
-
@Rizier123 i don't believe that is what he is asking – Jul 20 '15 at 00:05
-
So what makes a system unique? In what context are you using this? You want to identify the machine some code is running on? What about the system's hostname or a public key generated for each machine? A hash of the ssh hostkey perhaps? – Will Jul 20 '15 at 00:06
-
I'm guessing something along the lines of a mac address – Bankzilla Jul 20 '15 at 00:07
-
Something like that Will – Ender Graphix Jul 20 '15 at 00:18
-
even saying a "computer" really isn't specific enough. please explain the use of this unique ID then we can help you appropriately – Jul 20 '15 at 00:21
-
I have a server. When a computer will connect to that server using a software, it will generate a user file. The name for that file used is the computer's REMOTE_ADDR.Sience all REMOTE_ADDRs are 107.0.0.0.1, if more than 1 computer will connect to that server, it will rewrite the file that already exists. – Ender Graphix Jul 20 '15 at 00:25
-
the software on the remote server should send an id – Jul 20 '15 at 00:27
-
I wrote the server myself and it's using wamp as hosting. – Ender Graphix Jul 20 '15 at 00:28
-
$ipa = $_SERVER['REMOTE_ADDR']; – Ender Graphix Jul 20 '15 at 00:29
-
what protocol is remote computer using to access server? – Jul 20 '15 at 00:29
-
if (!(file_exists("Users//" . $ip))){ $my_file = "Users//" . $ipa; $handle = fopen($my_file, 'w') or die('Cannot open file: '. $my_file); $data = 'null'; fwrite($handle, $data); $out = "DONE!"; } – Ender Graphix Jul 20 '15 at 00:29
-
It's connecting trough port 80 – Ender Graphix Jul 20 '15 at 00:29
-
IP is not computer\user unique – Jul 20 '15 at 00:30
-
I know that's why I want to find a value to replace $ipa – Ender Graphix Jul 20 '15 at 00:30
-
it's actually connecting to my localhost.That's where the server is hosted, trough port forwarding. – Ender Graphix Jul 20 '15 at 00:31
-
sorry to many missing details for me. – Jul 20 '15 at 00:31
1 Answers
1
You won't reliably be able to obtain a MAC address from an end user. You can't use the hostname because the hostname exposed is based off of the IP address and they are all connecting through the same IP.
The only other way I could think of doing this is using a cookie or authentication. If they authenticate, then you use their user ID. If not, then you can set a long term cookie with a uniquely generated ID. For instance:
if (empty($_COOKIE['machine_id'])) {
$id = md5(uniqid(rand(), true));
setcookie('machine_id', $id, time()+(3*365*86400));
}
Then this client would need have a unique identifier for future connections in the machine_id cookie.
This would be dependent on a client enabling cookies and not clearing their cookies.

Devon Bessemer
- 34,461
- 9
- 69
- 95
-
im not even clear this is a http connection, and if its not dont expect cookies to be passed. but this could work - if you have 100% control over the remote machine (which if you did there are better ways). but OP is making this to hard to answer - so good luck – Jul 20 '15 at 00:34