这是可能的。你需要做的是切换会话数据。您可以使用以下代码执行此操作:
$switchSessionName = 'adminhtml';
if (!empty($_COOKIE[$switchSessionName])) {
$currentSessionId = Mage::getSingleton('core/session')->getSessionId();
$currentSessionName = Mage::getSingleton('core/session')->getSessionName();
if ($currentSessionId && $currentSessionName && isset($_COOKIE[$currentSessionName])) {
$switchSessionId = $_COOKIE[$switchSessionName];
$this->_switchSession($switchSessionName, $switchSessionId);
$whateverData = Mage::getModel('mymodule/session')->getWhateverData();
$this->_switchSession($currentSessionName, $currentSessionId);
}
}
protected function _switchSession($namespace, $id = null) {
session_write_close();
$GLOBALS['_SESSION'] = null;
$session = Mage::getSingleton('core/session');
if ($id) {
$session->setSessionId($id);
}
$session->start($namespace);
}
我最终加密一个cookie并设置会话在数据库中处理它。你是对的,没有任何运气做任何“官方”的方式。 – 2012-11-04 16:42:47
是的,我们也考虑过这种方式,最终获得了“IP开发人员功能”,就像在magento配置中一样。我认为,如果我们将会话的名称都改为相同的值,那应该没有问题。但这是安全措施吗? – 2012-11-05 10:08:03
我不会将会话更改为相同的,只是因为听起来您可能会遇到无法预料的后果。加密的cookie对我来说非常适合,而且您不必混淆IP。在这里实现:https://github.com/zschuessler/QuarkBar – 2012-11-05 15:45:27