Count Unique Visits to the Drupal Site
Try the Visitors module to either use it or help you with your code. It provides many features concerning visitors info and among them is the "unique visitor" feature you are interested in. A similar approach would be also the Counter module.