Review how cookie works

This commit is contained in:
Michael RICOIS 2017-12-18 14:39:57 +01:00
parent 1293f573b6
commit 326de6a61f

View File

@ -1160,10 +1160,6 @@ RewriteRule ^invite/(.*)$ '.__PS_BASE_URI__.'modules/invite/sponsor.php?sponsor=
&& ($customer = $customer->getByEmail($email))
&& Validate::isLoadedObject($customer)) {
$smarty->assign(array(
'sponsor_email' => $email,
));
if(Module::isInstalled('trackingtag') && Db::getInstance()->getRow('
SELECT `id_trackingtag`
FROM `'._DB_PREFIX_.'trackingtag`
@ -1172,7 +1168,7 @@ RewriteRule ^invite/(.*)$ '.__PS_BASE_URI__.'modules/invite/sponsor.php?sponsor=
AND `enabled` = 1
')) {
$smarty->assign(array(
'hide_sponsor' => TRUE,
'hide_sponsor' => true,
));
//get tracking info
@ -1190,7 +1186,6 @@ RewriteRule ^invite/(.*)$ '.__PS_BASE_URI__.'modules/invite/sponsor.php?sponsor=
'tag_auth' => $tr_infos['tag_auth'],
));
}
}
if($c = Db::getInstance()->getRow('
@ -1204,14 +1199,21 @@ RewriteRule ^invite/(.*)$ '.__PS_BASE_URI__.'modules/invite/sponsor.php?sponsor=
}
}
if(isset($_COOKIE['4598484FDSFDSREFERAL8849FDS'])){
$referal_email = base64_decode($_COOKIE['4598484FDSFDSREFERAL8849FDS']);
$smarty->assign('sponsor_email', $referal_email);
} else {
if (isset($customer)) {
setcookie('4598484FDSFDSREFERAL8849FDS', base64_encode($customer->email), time() + 3600 * 24, '/', 'bebeboutik.com');
}
// Cookie
$referal_email = '';
$cName = '4598484FDSFDSREFERAL8849FDS';
if (Validate::isLoadedObject($customer)) {
$referal_email = $customer->email;
} elseif (isset($_COOKIE[$cName])) {
$referal_email = base64_decode($_COOKIE[$cName]);
}
// Init cookie
if ($_COOKIE[$cName] != base64_encode($referal_email)) {
unset($_COOKIE[$cName]);
}
setcookie($cName, base64_encode($referal_email), time() + 3600 * 24, '/', 'bebeboutik.com');
$smarty->assign('sponsor_email', $referal_email);
return $this->display(__FILE__, 'authentication.tpl');
}