It appears as though the script is just trying to save some time by checking if a person/user already has a cookie file that identifies them as already existing. The sub routine:
is just reading a cookie file stored on the users computer. The cookie file is in a specific format:
key=value;key=value;key=value
the script first splits up the cookie into an array by splitting the cookie on the semi-colon so it gets:
@rawCookies= ('key=value','key=value','key=value');
then it loops through that array and splits the key/value pairs into a hash: %cookies:
$cookies{$keys} = $value;
and return the hash back to the caller:
return %cookies;
one of those hash keys is evidently 'AffiliateID' which lets your script know the user already exists if it finds this inthe cookie file. Of course many people block cookies so the user may have to login or something else so your script knows they already exist.