本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\SessionInterface::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionInterface::getName方法的具体用法?PHP SessionInterface::getName怎么用?PHP SessionInterface::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Session\SessionInterface
的用法示例。
在下文中一共展示了SessionInterface::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_logs_user_out(SessionInterface $session, CookieSetterInterface $cookieSetter)
{
$session->set('_security_shop', null)->shouldBeCalled();
$session->save()->shouldBeCalled();
$session->getName()->willReturn('MOCKEDSID');
$session->getId()->willReturn('xyzc123');
$cookieSetter->setCookie('MOCKEDSID', 'xyzc123')->shouldBeCalled();
$this->logOut();
}
示例2: logInUser
/**
* @param UserInterface $user
*/
private function logInUser(UserInterface $user)
{
$token = new UsernamePasswordToken($user, $user->getPassword(), 'randomstringbutnotnull', $user->getRoles());
$this->session->set($this->sessionTokenVariable, serialize($token));
$this->session->save();
$this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
}
示例3: testSetName
public function testSetName()
{
$this->assertEquals('MOCKSESSID', $this->session->getName());
$this->session->setName('session.test.com');
$this->session->start();
$this->assertEquals('session.test.com', $this->session->getName());
}
示例4: generateCookie
protected function generateCookie()
{
$lifetime = $this->options->getInt('cookie_lifetime');
if ($lifetime !== 0) {
$lifetime += time();
}
return new Cookie($this->session->getName(), $this->session->getId(), $lifetime, $this->options['cookie_path'], $this->options['cookie_domain'] ?: null, $this->options->getBoolean('cookie_secure'), $this->options->getBoolean('cookie_httponly'));
}
示例5: writeSessionTo
/**
* Write the session cookie to the response.
*
* @param \Symfony\Component\HttpFoundation\Response $response
* @return void
*/
protected function writeSessionTo(Response $response)
{
// TODO: Take these values from config
$lifetime = Carbon::now()->addMinutes(120);
$path = '/';
$domain = null;
$secure = false;
$response->headers->setCookie(new Cookie($this->session->getName(), $this->session->getId(), $lifetime, $path, $domain, $secure));
}
示例6: onSiteAccessMatch
public function onSiteAccessMatch(PostSiteAccessMatchEvent $event)
{
if (!($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST && isset($this->session) && !$this->session->isStarted() && $this->sessionStorage instanceof NativeSessionStorage)) {
return;
}
$sessionOptions = (array) $this->configResolver->getParameter('session');
$sessionName = isset($sessionOptions['name']) ? $sessionOptions['name'] : $this->session->getName();
$sessionOptions['name'] = $this->getSessionName($sessionName, $event->getSiteAccess());
$this->sessionStorage->setOptions($sessionOptions);
}
示例7: logIn
/**
* {@inheritdoc}
*/
public function logIn($email, $providerKey, Session $minkSession)
{
$user = $this->userRepository->findOneBy(['username' => $email]);
if (null === $user) {
throw new \InvalidArgumentException(sprintf('There is no user with email %s', $email));
}
$token = new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles());
$this->session->set('_security_user', serialize($token));
$this->session->save();
$minkSession->setCookie($this->session->getName(), $this->session->getId());
}
示例8: getConfig
public function getConfig()
{
$sessionInfo = ['isStarted' => false];
if ($this->session->isStarted()) {
$sessionInfo['isStarted'] = true;
$sessionInfo['name'] = $this->session->getName();
$sessionInfo['identifier'] = $this->session->getId();
$sessionInfo['csrfToken'] = $this->csrfTokenManager->getToken($this->csrfTokenIntention)->getValue();
$sessionInfo['href'] = $this->generateUrl('ezpublish_rest_deleteSession', ['sessionId' => $this->session->getId()]);
}
return $sessionInfo;
}
示例9: onSiteAccessMatch
public function onSiteAccessMatch(PostSiteAccessMatchEvent $event)
{
if (!$this->session || $event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
return;
}
$sessionName = $this->session->getName();
$request = $event->getRequest();
if (!$this->session->isStarted() && !$request->hasPreviousSession() && $request->request->has($sessionName)) {
$this->session->setId($request->request->get($sessionName));
$this->session->start();
}
}
示例10: onKernelRequest
public function onKernelRequest(GetResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
$request = $event->getRequest();
if ($request->request->has('sessionId')) {
$request->cookies->set($this->session->getName(), 1);
$sessionId = $this->encryption->decrypt($request->request->get('sessionId'));
$this->session->setId($sessionId);
}
}
示例11: setToken
/**
* @param TokenInterface $token
*/
private function setToken(TokenInterface $token)
{
$serializedToken = serialize($token);
$this->session->set($this->sessionTokenVariable, $serializedToken);
$this->session->save();
$this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
}
示例12: onBuildKernelHandler
/**
* Adds the session settings to the parameters that will be injected
* into the legacy kernel
*
* @param \eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent $event
*/
public function onBuildKernelHandler(PreBuildKernelEvent $event)
{
$sessionInfos = array('configured' => false, 'started' => false, 'name' => false, 'namespace' => false, 'has_previous' => false, 'storage' => false);
if (isset($this->session)) {
$sessionInfos['configured'] = true;
$sessionInfos['name'] = $this->session->getName();
$sessionInfos['started'] = $this->session->isStarted();
$sessionInfos['namespace'] = $this->sessionStorageKey;
$sessionInfos['has_previous'] = isset($this->request) ? $this->request->hasPreviousSession() : false;
$sessionInfos['storage'] = $this->sessionStorage;
}
$legacyKernelParameters = $event->getParameters();
$legacyKernelParameters->set('session', $sessionInfos);
// Deactivate session cookie settings in legacy kernel.
// This will force using settings defined in Symfony.
$sessionSettings = array('site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false);
$legacyKernelParameters->set("injected-settings", $sessionSettings + (array) $legacyKernelParameters->get("injected-settings"));
}
示例13: makeCookie
protected function makeCookie(Request $request)
{
// merge native PHP session cookie params with custom ones.
$params = array_replace(session_get_cookie_params(), $this->cookies);
// if the cookie lifetime is not 0 (closes when browser window closes),
// add the request time and the lifetime to get the expiration time of
// the cookie.
if ($params['lifetime'] !== 0) {
$params['lifetime'] = $request->server->get('REQUEST_TIME') + $params['lifetime'];
}
return new Cookie($this->session->getName(), $this->session->getId(), $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
}
示例14:
function it_logs_user_in(UserRepositoryInterface $userRepository, SessionInterface $session, CookieSetterInterface $cookieSetter, UserInterface $user)
{
$userRepository->findOneBy(['username' => 'sylius@example.com'])->willReturn($user);
$user->getRoles()->willReturn(['ROLE_USER']);
$user->getPassword()->willReturn('xyz');
$user->serialize()->willReturn('serialized_user');
$session->set('_security_context_name', Argument::any())->shouldBeCalled();
$session->save()->shouldBeCalled();
$session->getName()->willReturn('MOCKEDSID');
$session->getId()->willReturn('xyzc123');
$cookieSetter->setCookie('MOCKEDSID', 'xyzc123')->shouldBeCalled();
$this->logIn('sylius@example.com');
}
示例15: login
/**
* @param BaseUser $user
* @param SessionInterface $session
* @param $firewall
* @throws UnsupportedDriverActionException
*/
public function login(BaseUser $user, SessionInterface $session, $firewall)
{
$driver = $this->getDriver();
if (!$driver instanceof BrowserKitDriver) {
//Fall back to manual login if BrowserKitDriver is not used
throw new UnsupportedDriverActionException("Not supported by the current driver", $driver);
}
$client = $driver->getClient();
$client->getCookieJar()->set(new Cookie(session_name(), true));
$token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
$session->set('_security_' . $firewall, serialize($token));
$session->save();
$cookie = new Cookie($session->getName(), $session->getId());
$client->getCookieJar()->set($cookie);
}