本文整理匯總了PHP中Stream::session方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stream::session方法的具體用法?PHP Stream::session怎麽用?PHP Stream::session使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Stream
的用法示例。
在下文中一共展示了Stream::session方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_session
public static function get_session()
{
if (!self::$session) {
// Generate the session ID. This is slightly wasteful.
$data = array();
$data['type'] = 'stream';
// This shouldn't be done here but at backend endpoint side
if (isset($_REQUEST['client'])) {
$data['agent'] = $_REQUEST['client'];
}
// Copy session geolocation
// Same thing, should be done elsewhere
$sid = session_id();
if ($sid) {
$location = Session::get_geolocation($sid);
if (isset($location['latitude'])) {
$data['geo_latitude'] = $location['latitude'];
}
if (isset($location['longitude'])) {
$data['geo_longitude'] = $location['longitude'];
}
if (isset($location['name'])) {
$data['geo_name'] = $location['name'];
}
}
self::$session = Session::create($data);
}
return self::$session;
}
示例2: _auto_init
/**
* auto_init
* This is called on class load it sets the session
*/
public static function _auto_init()
{
// Generate the session ID. This is slightly wasteful.
$data = array();
$data['type'] = 'stream';
if (isset($_REQUEST['client'])) {
$data['agent'] = $_REQUEST['client'];
}
self::$session = Session::create($data);
}