diff --git a/public/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php b/public/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php index edaa94d2..d957c842 100644 --- a/public/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php +++ b/public/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php @@ -62,22 +62,29 @@ class BookingUrlUtility $query = static::buildQuery($bookingId, $hotelId, $dateEnd, $template, $isDayTrip); - $cookie = $_COOKIE[static::COOKIE_NAME]; - if (strpos($cookie, '?') !== false) { - $items = GeneralUtility::trimExplode('?', $cookie); - $cookie = $items[0]; - } - $bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN]; + $trackingCookie = null; + $bpnCookie = null; - if ($paCode !== null) { - $query['agenturcode'] = $paCode; - } elseif (!empty($bpnCookie)) { - $query['agenturcode'] = $bpnCookie; - } elseif (!empty($cookie)) { - if (preg_match('/^P[a-zA-Z0-9]*/', $cookie)) { - $query['agenturcode'] = $cookie; + if (isset($_COOKIE[static::COOKIE_NAME])) { + if (false === preg_match('/([a-z]{4}|PA)\d{4}/', $_COOKIE[static::COOKIE_NAME])) { + setcookie(static::COOKIE_NAME, '', time() - 3600); } else { - $query['crminfo'] = $cookie; + $trackingCookie = $_COOKIE[static::COOKIE_NAME]; + } + } + if (isset($_COOKIE[static::COOKIE_NAME_BPN])) { + $bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN]; + } + + if ($paCode) { + $query['agenturcode'] = $paCode; + } elseif ($bpnCookie) { + $query['agenturcode'] = $bpnCookie; + } elseif ($trackingCookie) { + if (preg_match('/^PA\d+/', $trackingCookie)) { + $query['agenturcode'] = $trackingCookie; + } else { + $query['crminfo'] = $trackingCookie; } }