Browse code

Set cookie for subdomain if any to prevent wildcard cookie policy across one TLD

Benjamin Roth authored on28/06/2017 22:20:35
Showing1 changed files
... ...
@@ -92,9 +92,9 @@ class CookiePolicy extends \Frontend
92 92
 
93 93
 		if (\Input::get('cookiepolicy_commit') == $_SESSION['eSM_cookiepolicy_token'])
94 94
 		{
95
-			preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', \Environment::get('host'), $regs);
95
+			preg_match('/(?P<subdomain>[a-z0-9][a-z0-9\-]{1,63}|)\.(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', \Environment::get('host'), $regs);
96 96
 
97
-			setcookie('eSM_cookiepolicy_passed', true, time()+31536000, '/','.'.$regs['domain']);
97
+			setcookie('eSM_cookiepolicy_passed', true, time()+31536000, '/',$regs['subdomain'].'.'.$regs['domain']);
98 98
 			unset($_SESSION['eSM_cookiepolicy_token']);
99 99
 
100 100
 			return true;