private function storeFrontendReferrer()
	{
		$base = \Environment::get('path');
		$base .= \System::getContainer()->get('router')->generate('contao_backend');

		$referrer = parse_url(\Environment::get('httpReferer'));
		$referrer = $referrer['path'] . ($referrer['query'] ? '?' . $referrer['query'] : '');

		// Stop if the referrer is a backend URL
		if (
			substr($referrer, 0, strlen($base)) === $base
			&& in_array(substr($referrer, strlen($base), 1), array(false, '/', '?'), true)
		) {
			return;
		}

		// Fix empty referrers
		if (empty($referrer)) {
			$referrer = '/';
		}

		// Make homepage possible as referrer
		if ($referrer === \Environment::get('path') . '/') {
			$referrer .= '?';
		}

		$referrer = \Environment::get('path') . '/bundles/rocksolidfrontendhelper/html/referrer.html?referrer=' . rawurlencode($referrer);

		// set the frontend URL as referrer

		$referrerSession = \System::getContainer()->get('session')->get('referer');

		if (defined('TL_REFERER_ID') && !\Input::get('ref')) {

			$referrer = substr($referrer, strlen(TL_PATH) + 1);
			$tlRefererId = substr(md5(TL_START - 1), 0, 8);
			$referrerSession[$tlRefererId]['current'] = $referrer;
			\Input::setGet('ref', $tlRefererId);
			$requestUri = \Environment::get('requestUri');
			$requestUri .= (strpos($requestUri, '?') === false ? '?' : '&') . 'ref=' . $tlRefererId;
			\Environment::set('requestUri', $requestUri);
			\System::getContainer()->get('request_stack')->getCurrentRequest()->query->set('ref', $tlRefererId);

		}

		\System::getContainer()->get('session')->set('referer', $referrerSession);
	}