php - Retrieve data from session with PHPSESSID in Memcache -
i'm using memcahe/d store sessions in magento, how retrieve data stored inside session phpsessid
given?
need this:
$sessionfilepath =file_get_contents('path/to/session/sess_'.$_cookie['adminhtml']);
but system based on memcache/d storage instead of files.
let's supposes that:
$session_save_path='tcp://10.0.0.1:11211?persistent=1&weight=2&timeout=10&retry_interval=10'
is session.save_path
value
assuming $savemethod
can equal memcache
or memcached
(memcached
should support magento, in case..) (in real enviroment can db
or files
):
$locaxml = mage::getbasedir('etc').ds.'local.xml'; $xml = new domdocument(); $xml->load($locaxml); $xpath = new domxpath($xml); $entry = $xpath->query("//session_save"); foreach($entry $ent){ $savemethod = trim($ent->nodevalue); } $savemethod=(!empty($savemethod))? $savemethod:'files'; $entry = $xpath->query("//session_save_path"); foreach($entry $ent){ $session_path = $ent->nodevalue; } if(strpos($session_path,'?')!==false){ $session_path=(explode('?',$session_path)); $session_path=$session_path[0]; } $session_path=explode(':',$session_path); $port= $session_path[count($session_path)-1]; unset($session_path[count($session_path)-1]); $host=implode(':',$session_path); if($savemethod=='memcache'){ $m = new memcache(); $m = memcache_connect($host, $port); } else if($savemethod=='memcached'){ $m = new memcached(); $m->addserver($host, $port); } $session_data= $m->get({{phpsessid_value}});
Comments
Post a Comment