Created
December 30, 2013 15:02
-
-
Save ericsk/8183080 to your computer and use it in GitHub Desktop.
WindowsAzureSessionHandler 的 Read 方法
This file contains hidden or 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
/** | |
* Callback function for session handler. It's invoked while the session data is being read. | |
* | |
* @param $sessionId The session ID. | |
* | |
* @return string The session data. It will retrun empty string if the session doesn't exist. | |
*/ | |
public function read($sessionId) { | |
try { | |
// try to retrieve the session content first to see if it exists | |
$result = $this->_tableRestProxy->getEntity($this->_sessionContainer, $this->_sessionContainerPartition, $sessionId); | |
// get the entity instance | |
$entity = $result->getEntity(); | |
// deflat the serialized data | |
return unserialize(base64_decode($entity->getPropertyValue('data'))); | |
} catch (ServiceException $e) { | |
// the entity doesn't exist, return empty string according to the spec: | |
// http://www.php.net/manual/en/sessionhandlerinterface.read.php | |
return ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment