There are any number of ways to store this information and cookies would not have come to my mind as a solution to your problem. You need a record of $ENV{HTTP_REFERER} for each visitor so write it to a flat file on the server or store it in a database table if you have db access.
"The man who grasps principles can successfully
select his own methods.
The man who tries methods,
ignoring principles, is sure to have trouble.