本文整理汇总了PHP中Magento\Framework\Session\SessionManagerInterface::getSessionId方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManagerInterface::getSessionId方法的具体用法?PHP SessionManagerInterface::getSessionId怎么用?PHP SessionManagerInterface::getSessionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Session\SessionManagerInterface
的用法示例。
在下文中一共展示了SessionManagerInterface::getSessionId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetSessionIdFromParam
/**
* @magentoConfigFixture current_store web/session/use_frontend_sid 1
*/
public function testSetSessionIdFromParam()
{
$this->assertNotEquals('test_id', $this->_model->getSessionId());
$_GET[$this->_sidResolver->getSessionIdQueryParam($this->_model)] = 'test-id';
$this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
$this->assertEquals('test-id', $this->_model->getSessionId());
/* Use not valid identifier */
$_GET[$this->_sidResolver->getSessionIdQueryParam($this->_model)] = 'test_id';
$this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
$this->assertEquals('test-id', $this->_model->getSessionId());
}
示例2: getSafeSessionId
/**
* Get a hash of the session id.
*
* @return string|null
*/
protected function getSafeSessionId()
{
if (!$this->safeSessionId) {
// When there is no session id, safeSessionId will be set to null.
// This will prevent the method call from getting cached (above
// check will fail) and cause the session to be rechecked for a
// session id on successive calls until a session id is retrieved.
// Allowing this behavior in case a log call happens before the
// session is started. Some calls may miss the session id but once
// it is available, it will be retrieved, cached and attached to
// later log calls.
$sessionId = $this->session->getSessionId();
$this->safeSessionId = $sessionId ? hash('sha256', $this->session->getSessionId()) : null;
}
return $this->safeSessionId;
}
示例3: updatePathParams
/**
* {@inheritdoc}
*
* @param array $arguments
* @return array
*/
public function updatePathParams(array $arguments)
{
if ($this->_session->getCookieShouldBeReceived() && $this->_sidResolver->getUseSessionInUrl() && $this->_canUseSessionIdInParam) {
$arguments += ['_query' => [$this->_sidResolver->getSessionIdQueryParam($this->_session) => $this->_session->getSessionId()]];
}
return $arguments;
}
示例4: redirect
/**
* Set redirect into response
*
* @param \Magento\Framework\App\ResponseInterface $response
* @param string $path
* @param array $arguments
* @return void
*/
public function redirect(\Magento\Framework\App\ResponseInterface $response, $path, $arguments = array())
{
if ($this->_session->getCookieShouldBeReceived() && $this->_urlBuilder->getUseSession() && $this->_canUseSessionIdInParam) {
$arguments += array('_query' => array($this->_sidResolver->getSessionIdQueryParam($this->_session) => $this->_session->getSessionId()));
}
$response->setRedirect($this->_urlBuilder->getUrl($path, $arguments));
}
示例5: _saveCache
/**
* Save block content to cache storage
*
* @param string $data
* @return $this
*/
protected function _saveCache($data)
{
if ($this->getCacheLifetime() === null || !$this->_cacheState->isEnabled(self::CACHE_GROUP)) {
return false;
}
$cacheKey = $this->getCacheKey();
$data = str_replace($this->_sidResolver->getSessionIdQueryParam($this->_session) . '=' . $this->_session->getSessionId(), $this->_getSidPlaceholder($cacheKey), $data);
$this->_cache->save($data, $cacheKey, $this->getCacheTags(), $this->getCacheLifetime());
return $this;
}
示例6: initByRequest
/**
* Initialization visitor by request
*
* Used in event "controller_action_predispatch"
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\Customer\Model\Visitor
*/
public function initByRequest($observer)
{
if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) {
return $this;
}
if ($this->session->getVisitorData()) {
$this->setData($this->session->getVisitorData());
}
if (!$this->getId()) {
$this->setSessionId($this->session->getSessionId());
$this->save();
$this->_eventManager->dispatch('visitor_init', array('visitor' => $this));
$this->session->setVisitorData($this->getData());
}
return $this;
}
示例7: initByRequest
/**
* Initialization visitor by request
*
* Used in event "controller_action_predispatch"
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\Customer\Model\Visitor
*/
public function initByRequest($observer)
{
if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) {
return $this;
}
if ($this->session->getVisitorData()) {
$this->setData($this->session->getVisitorData());
}
$this->setLastVisitAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
if (!$this->getId()) {
$this->setSessionId($this->session->getSessionId());
$this->save();
$this->_eventManager->dispatch('visitor_init', ['visitor' => $this]);
$this->session->setVisitorData($this->getData());
}
return $this;
}