How can I store JSON data in Memcached using the adapter given in the Incubator. I have been trying so many ways but cannot get it to work. These are the functions I have extended:
public function read($sessionId){
$tmp = $_SESSION;
$_SESSION = json_decode($this->_getMemcacheInstance()->get($this->_getSessionId($sessionId), $this->getOption('lifetime')),true);
if(isset($_SESSION) && !empty($_SESSION) && $_SESSION != null){
$new_data = session_encode();
$_SESSION = $tmp;
return $new_data;
} else{
return "";
}
}
/**
* Writes data into session object
*
* @param string $sessionId
* @param string $data
*/
public function write($sessionId, $data) {
$tmp = $_SESSION;
session_decode($data);
$serializedData = json_encode($_SESSION);
$_SESSION = $tmp;
$this->_getMemcacheInstance()->save($this->_getSessionId($sessionId), $serializedData, $this->getOption('lifetime'));
}
The function write does not write the correct data to Memcached.
This is the data I want to have in Memcached:
{"auth": {"id": 1, "name": "gasimzada"}} but I get:
a:1:{s:4:"auth";a:2:{s:2:"id";s:1:"1";s:4:"name";s:9:"gasimzada";}}
What am I doing wrong?
Thanks, Gasim