Skip to content

Instantly share code, notes, and snippets.

@bzdk
Created December 10, 2014 06:07
Show Gist options
  • Save bzdk/bd9c8dde9828bfc5c022 to your computer and use it in GitHub Desktop.
Save bzdk/bd9c8dde9828bfc5c022 to your computer and use it in GitHub Desktop.
[OpenCart 1.5.6] Cookie manipulate on user switch between multiple instance under same domain
// =============================================
// Cookie reset for multiple-cart(same domain)
// =============================================
$oc156_instance_id = 'us';
if (isset($_COOKIE['oc156_instance'])) {
if ($_COOKIE['oc156_instance'] != $oc156_instance_id) {
// clean session
unset($_COOKIE['PHPSESSID']);
// update lang/currency cookie
unset($_COOKIE['language']);
setcookie('language', 'en', time() + 60 * 60 * 24 * 30, '/', $_SERVER['HTTP_HOST']);
unset($_COOKIE['currency']);
setcookie('currency', 'USD', time() + 60 * 60 * 24 * 30, '/', $_SERVER['HTTP_HOST']);
// update region cookie
unset($_COOKIE['oc156_instance']);
setcookie('oc156_instance', $oc156_instance_id, time() + 60 * 60 * 24 * 30, '/', $_SERVER['HTTP_HOST']);
}
} else {
setcookie('oc156_instance', $oc156_instance_id, time() + 60 * 60 * 24 * 30, '/', $_SERVER['HTTP_HOST']);
}
// =============================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment