Skip to content

Instantly share code, notes, and snippets.

@ericsk
Created December 30, 2013 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericsk/8183051 to your computer and use it in GitHub Desktop.
Save ericsk/8183051 to your computer and use it in GitHub Desktop.
WindowsAzureSessionHandler 的建構與解構函式
/**
* Session handler constructor.
*
* @param $storageAccountName The Windows Azure Table Services account name.
* @param $storageAccountKey The Windows Azure Table Service account key.
* @param $sessionContainer The name of the table for storing session data.
* @param $sessionContainerParition The name of the partition for storing session data.
*/
public function __construct($storageAccountName, $storageAccountKey, $sessionContainer = 'phpsessions', $sessionContainerPartition = 'sessions') {
// create the conneciton string for creating the table service rest proxy intance.
$connectionString = "DefaultEndpointsProtocol=https;AccountName=" .
$storageAccountName .
";AccountKey=" .
$storageAccountKey;
// create the table service instance.
$this->_tableRestProxy = ServiceBuilder::getInstance()->createTableService($connectionString);
// set up the table and partition names.
$this->_sessionContainer = $sessionContainer;
$this->_sessionContainerPartition = $sessionContainerPartition;
// register the session shutdown function.
register_shutdown_function('session_write_close');
}
/**
* Destructor.
*/
public function __destruct() {
session_write_close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment