<?php

namespace Easymailing\App\Core\Provider\Woocommerce\Hooks;

class CampaignHashHook
{
	const CAMPAIGN_HASH_COOKIE = 'easymailing_plugin_em_ch';

	public function saveCampaignHash()
	{
		if ( isset($_GET['em_ch']) ) {
			$campaignHash = sanitize_text_field($_GET['em_ch']);
			$expirationTime = time() + (30 * 24 * 60 * 60);
			setcookie(self::CAMPAIGN_HASH_COOKIE, $campaignHash, $expirationTime, COOKIEPATH, COOKIE_DOMAIN);
		}
	}

}
