If you want to redirect visitor to affiliate's replicated based on the information from cookie you can use following API code:
<?php
include_once('PapApi.class.php');
$session = new Pap_Api_Session("URL_TO_PAP/scripts/server.php");
// register click
$clickTracker = new Pap_Api_ClickTracker($session);
try {
$clickTracker->track();
$clickTracker->save3rdPartyCookiesOnly();
} catch (Exception $e) {
}
$refid = 'testaff'; // default affiliate
if ($clickTracker->getAffiliate() != null) {
$refid = $clickTracker->getAffiliate()->getValue('refid');
}
header('Location: URL_TO_REPLICATED_SITE/'.$refid);
?>
Do not forget to modify the code so it uses correct URLs and default affiliate.