You are here: Home
Support site for Tips and Tricks HQ premium products
example1.com
example1.com/site2
Just like that, we had a temporary solution by terminating the session if a user switched sites, so there no cart items will travel from site to site. We added this to our index.php
$locationArray = explode('/', $_SERVER['REQUEST_URI']);
$store_id = $locationArray[1];
if ($store_id == 'favicon.ico') {
$store_id = 'other';
}
if (!(isset($_COOKIE['store_id']))) {
if ($store_id != 'other') {
setcookie('store_id', $store_id, mktime(0,0,0,date("n")+1,date("j"),date("Y")), '/', $_SERVER['SERVER_NAME'], false, true);
}
} else {
if (($_COOKIE['store_id'] != $store_id) && ($store_id != 'other')) {
session_destroy();
$params = session_get_cookie_params();
setcookie('PHPSESSID', '', time()-42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
setcookie('cart_in_use', '', time()-3600);
setcookie('store_id', $store_id, mktime(0,0,0,date("n")+1,date("j"),date("Y")), '/', $_SERVER['SERVER_NAME'], false, true);
}
}
Any better ideas?
Chase