why do you need a cookie at all?
when a guest connects, record the IP - set your code to only record an IP which is not already existing in the list
there you go. done. No cookie needed, all code is server side.
(actually, SMF et all already do exactly this)