shakac
shakac

Reputation: 379

How to identify each pc as unique connected with same ip address in php

I am struggling to find out a way in php to identify each pc as a unique pc that are connected with same ip address.i am making a visitor statistics plugin everything working fine but when 4-5 pc browse my site with same ip it shows only one visitor online because of same ip.i could not figure out how to overcome this. please anyone help. thank you

Upvotes: 1

Views: 271

Answers (2)

Paul Spiegel
Paul Spiegel

Reputation: 31772

if (isset($_COOKIE['tracking_id'])) {
    $trackingId = $_COOKIE['tracking_id'];
} else {
    $trackingId = uniqid();
}
$expire = strtotime('+30 days');
$path = '/';
setcookie('tracking_id', $trackingId, $expire, $path);
// log using $trackingId

Note that $trackingId identifies a browser - not a PC. If a user changes the browser or another user logs in on the PC you will get a new ID.

Upvotes: 1

Roberto
Roberto

Reputation: 21

It's very difficult to get a MAC address of a machine that's in a separate network from the server.

I would avoid tracking session variables, mainly because I would not want to take the chance that the session variable gets captured and used for session spoofing.

I would suggest generating a cookie with a unique variable for each machine. (What that function would be is up to you.) Track IP address plus cookie variable to follow unique machines.

Upvotes: 0

Related Questions