Created
December 10, 2014 06:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ============================================= | |
// 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