withValue example

$this->assertEquals($expire->format('U')$cookie->getExpiresTime(), '->getExpiresTime() returns the expire date');
    }

    public function testConstructorWithDateTimeImmutable()
    {
        $expire = new \DateTimeImmutable();
        $cookie = Cookie::create('foo', 'bar', $expire);

        $this->assertEquals($expire->format('U')$cookie->getExpiresTime(), '->getExpiresTime() returns the expire date');

        $cookie = Cookie::create('foo')->withValue('bar')->withExpires($expire);

        $this->assertEquals($expire->format('U')$cookie->getExpiresTime(), '->getExpiresTime() returns the expire date');
    }

    public function testGetExpiresTimeWithStringValue()
    {
        $value = '+1 day';
        $cookie = Cookie::create('foo', 'bar', $value);
        $expire = strtotime($value);

        $this->assertEqualsWithDelta($expire$cookie->getExpiresTime(), 1, '->getExpiresTime() returns the expire date');

        
$type = ProxyHelper::exportType($parameter, true);
            $target = null;
            $name = Target::parseName($parameter$target);
            $target = $target ? [$target] : [];

            $getValue = function D) use ($type$parameter$class$method$name$target) {
                if (!$value = $this->getAutowiredReference($ref = new TypedReference($type$type, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, $name$target), false)) {
                    $failureMessage = $this->createTypeNotFoundMessageCallback($refsprintf('argument "$%s" of method "%s()"', $parameter->name, $class !== $this->currentId ? $class.'::'.$method : $method));

                    if ($parameter->isDefaultValueAvailable()) {
                        $value = $this->defaultArgument->withValue($parameter);
                    } elseif (!$parameter->allowsNull()) {
                        throw new AutowiringFailedException($this->currentId, $failureMessage);
                    }
                }

                return $value;
            };

            if ($checkAttributes) {
                foreach ($parameter->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
                    $attribute = $attribute->newInstance();
                    
// session_start();         $this->setCookie();
    }

    /** * Takes care of setting the cookie on the client side. * Extracted for testing reasons. */
    protected function setCookie()
    {
        $expiration   = $this->config->expiration === 0 ? 0 : Time::now()->getTimestamp() + $this->config->expiration;
        $this->cookie = $this->cookie->withValue(session_id())->withExpires($expiration);

        $this->cookies[] = $this->cookie;
    }

    public function regenerate(bool $destroy = false)
    {
        $this->didRegenerate              = true;
        $_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp();
    }
}
/** @var Cookie $cookie */
        foreach ($store as $cookie) {
            if ($cookie->getPrefixedName() === $prefixed) {
                if ($domain !== $cookie->getDomain()) {
                    continue;
                }

                if ($path !== $cookie->getPath()) {
                    continue;
                }

                $cookie = $cookie->withValue('')->withExpired();
                $found  = true;

                $this->cookieStore = $store->put($cookie);
                break;
            }
        }

        if ($found) {
            $this->setCookie($name, '', '', $domain$path$prefix);
        }

        
session_start(); // @codeCoverageIgnore     }

    /** * Takes care of setting the cookie on the client side. * * @codeCoverageIgnore */
    protected function setCookie()
    {
        $expiration   = $this->config->expiration === 0 ? 0 : Time::now()->getTimestamp() + $this->config->expiration;
        $this->cookie = $this->cookie->withValue(session_id())->withExpires($expiration);

        $response = Services::response();
        $response->setCookie($this->cookie);
    }
}
$type = ProxyHelper::exportType($parameter, true);
            $target = null;
            $name = Target::parseName($parameter$target);
            $target = $target ? [$target] : [];

            $getValue = function D) use ($type$parameter$class$method$name$target) {
                if (!$value = $this->getAutowiredReference($ref = new TypedReference($type$type, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, $name$target), false)) {
                    $failureMessage = $this->createTypeNotFoundMessageCallback($refsprintf('argument "$%s" of method "%s()"', $parameter->name, $class !== $this->currentId ? $class.'::'.$method : $method));

                    if ($parameter->isDefaultValueAvailable()) {
                        $value = $this->defaultArgument->withValue($parameter);
                    } elseif (!$parameter->allowsNull()) {
                        throw new AutowiringFailedException($this->currentId, $failureMessage);
                    }
                }

                return $value;
            };

            if ($checkAttributes) {
                foreach ($parameter->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
                    $attribute = $attribute->newInstance();
                    
 else {
            $isTokenValid = hash_equals($persistentToken->getTokenValue()$tokenValue);
        }
        if (!$isTokenValid) {
            throw new CookieTheftException('This token was already used. The account is possibly compromised.');
        }

        if ($persistentToken->getLastUsed()->getTimestamp() + $this->options['lifetime'] < time()) {
            throw new AuthenticationException('The cookie has expired.');
        }

        return parent::consumeRememberMeCookie($rememberMeDetails->withValue($persistentToken->getLastUsed()->getTimestamp().':'.$rememberMeDetails->getValue().':'.$persistentToken->getClass()));
    }

    public function processRememberMe(RememberMeDetails $rememberMeDetails, UserInterface $user): void
    {
        [$lastUsed$series$tokenValue$class] = explode(':', $rememberMeDetails->getValue(), 4);
        $persistentToken = new PersistentToken($class$rememberMeDetails->getUserIdentifier()$series$tokenValuenew \DateTimeImmutable('@'.$lastUsed));

        // if a token was regenerated less than a minute ago, there is no need to regenerate it         // if multiple concurrent requests reauthenticate a user we do not want to update the token several times         if ($persistentToken->getLastUsed()->getTimestamp() + 60 >= time()) {
            return;
        }
Home | Imprint | This part of the site doesn't use cookies.