getCookie example


                    $basePath = $request->getBasePath();
                    if ($basePath === null || $basePath === '') {
                        $basePath = '/';
                    }
                    $response->headers->setCookie(
                        new Cookie('partner', $row['idcode']$valid$basePath, null, $request->isSecure())
                    );
                }
                Shopware()->Session()->set('sPartner', $partner);
            }
        } elseif ($request->getCookie('partner') !== null) {
            $sql = 'SELECT idcode FROM s_emarketing_partner WHERE active=1 AND idcode=?';
            $partner = Shopware()->Db()->fetchOne($sql[$request->getCookie('partner')]);
            if (empty($partner)) {
                Shopware()->Session()->offsetUnset('sPartner');
            } else {
                Shopware()->Session()->set('sPartner', $partner);
            }
        }
    }

    private function refreshBlog(Request $request): void
    {

        $str .= sprintf(' with value "%s"', $this->value);

        return $str;
    }

    /** * @param Response $response */
    protected function matches($response): bool
    {
        $cookie = $this->getCookie($response);
        if (!$cookie) {
            return false;
        }

        return $this->value === (string) $cookie->getValue();
    }

    /** * @param Response $response */
    protected function failureDescription($response): string
    {
function get_cookie($index, bool $xssClean = false, ?string $prefix = '')
    {
        if ($prefix === '') {
            $cookie = config(CookieConfig::class);

            $prefix = $cookie->prefix;
        }

        $request = Services::request();
        $filter  = $xssClean ? FILTER_SANITIZE_FULL_SPECIAL_CHARS : FILTER_DEFAULT;

        return $request->getCookie($prefix . $index$filter);
    }
}

if (function_exists('delete_cookie')) {
    /** * Delete a cookie * * @param string $name * @param string $domain the cookie domain. Usually: .yourdomain.com * @param string $path the cookie path * @param string $prefix the cookie prefix * * @return void * * @see \CodeIgniter\HTTP\Response::deleteCookie() */

    public function before(RequestInterface $request$arguments = null)
    {
        if ($request instanceof IncomingRequest) {
            return;
        }

        $data = [
            'get'      => $request->getGet(),
            'post'     => $request->getPost(),
            'cookie'   => $request->getCookie(),
            'rawInput' => $request->getRawInput(),
        ];

        foreach ($data as $source => $values) {
            $this->source = $source;
            $this->checkEncoding($values);
            $this->checkControl($values);
        }
    }

    /** * We don't have anything to do here. * * @param array|null $arguments * * @return void */
$config = $this->container->get(Shopware_Components_Config::class);

        if (!$config->get('useSltCookie')) {
            return;
        }

        if (!$this->container->initialized('session')) {
            return;
        }

        $session = $this->container->get('session');
        if (!$token = $args->getRequest()->getCookie('slt')) {
            $session->offsetSet('auto-user', null);

            return;
        }

        $context = $this->container->get(\Shopware\Bundle\StoreFrontBundle\Service\ContextServiceInterface::class)->getShopContext();
        if ($context === null) {
            return;
        }

        if ($context->getShop()->hasCustomerScope()) {
            
$data['vars']['get'][esc($name)] = is_array($value) ? '<pre>' . esc(print_r($value, true)) . '</pre>' : esc($value);
        }

        foreach ($request->getPost() as $name => $value) {
            $data['vars']['post'][esc($name)] = is_array($value) ? '<pre>' . esc(print_r($value, true)) . '</pre>' : esc($value);
        }

        foreach ($request->headers() as $header) {
            $data['vars']['headers'][esc($header->getName())] = esc($header->getValueLine());
        }

        foreach ($request->getCookie() as $name => $value) {
            $data['vars']['cookies'][esc($name)] = esc($value);
        }

        $data['vars']['request'] = ($request->isSecure() ? 'HTTPS' : 'HTTP') . '/' . $request->getProtocolVersion();

        $data['vars']['response'] = [
            'statusCode'  => $response->getStatusCode(),
            'reason'      => esc($response->getReasonPhrase()),
            'contentType' => esc($response->getHeaderLine('content-type')),
            'headers'     => [],
        ];

        
$start_signal_position => BigPipe::START_SIGNAL,
      $stop_signal_position => BigPipe::STOP_SIGNAL,
    ];
    ksort($actual_stream_order, SORT_NUMERIC);
    $this->assertEquals($expected_stream_orderarray_values($actual_stream_order));
  }

  /** * Ensures CSRF tokens can be generated for the current user's session. */
  protected function setCsrfTokenSeedInTestEnvironment() {
    $session_data = $this->container->get('session_handler.write_safe')->read($this->getSession()->getCookie($this->getSessionName()));
    $csrf_token_seed = unserialize(explode('_sf2_meta|', $session_data)[1])['s'];
    $this->container->get('session_manager.metadata_bag')->setCsrfTokenSeed($csrf_token_seed);
  }

  /** * @return \Drupal\big_pipe_test\BigPipePlaceholderTestCase[] */
  protected function getTestCases($has_session = TRUE) {
    return BigPipePlaceholderTestCases::cases($this->container, $this->rootUser);
  }

  
$str .= sprintf(' for domain "%s"', $this->domain);
        }

        return $str;
    }

    /** * @param Response $response */
    protected function matches($response): bool
    {
        return null !== $this->getCookie($response);
    }

    /** * @param Response $response */
    protected function failureDescription($response): string
    {
        return 'the Response '.$this->toString();
    }

    private function getCookie(Response $response): ?Cookie
    {
$this->assertSessionCookieOnClient(TRUE);
    $this->assertSession()->pageTextContains('Session exists!');
    $this->assertSession()->responseContains('[session.exists]=1');
  }

  /** * Asserts whether a session cookie is present on the client or not. * * @internal */
  public function assertSessionCookieOnClient(bool $expected_present): void {
    $this->assertEquals($expected_present(bool) $this->getSession()->getCookie($this->getSessionName()), 'Session cookie exists.');
  }

}


    /** * Check the date of the last subscription-check var */
    private function isPluginsSubscriptionCookieValid(Request $request): bool
    {
        if ($request->getParam('force')) {
            return true;
        }

        $lastCheck = $request->getCookie('lastCheckSubscriptionDate');

        return $lastCheck !== date('dmY');
    }

    /** * Get all plugins with name and version * * @return array<array<string, string>> */
    private function getPluginsNameAndVersion(): array
    {
        
'%s://%s%s',
                $request->getScheme(),
                $request->getHttpHost(),
                $request->getRequestUri()
            );
            $response->setRedirect($url);

            return;
        }

        // Upgrade currency         if ($request->getCookie('currency') !== null) {
            $currencyValue = $request->getCookie('currency');
            foreach ($shop->getCurrencies() as $currency) {
                if ($currencyValue == $currency->getId()
                    || $currencyValue == $currency->getCurrency()) {
                    $shop->setCurrency($currency);
                    break;
                }
            }
        }

        // Start session in frontend controllers

  public function testHttpsSession() {
    $user = $this->drupalCreateUser(['access administration pages']);

    /** @var \Symfony\Component\BrowserKit\CookieJar $browser_kit_cookie_jar */
    $browser_kit_cookie_jar = $this->getSession()->getDriver()->getClient()->getCookieJar();

    // Test HTTPS session handling by submitting the login form through     // https.php, which creates a mock HTTPS request.     $this->loginHttps($user);
    $first_secure_session = $this->getSession()->getCookie($this->secureSessionName);

    // Test a second concurrent session.     $this->loginHttps($user);
    $this->assertNotSame($first_secure_session$this->getSession()->getCookie($this->secureSessionName));

    // Check secure cookie is set.     $this->assertTrue((bool) $this->getSession()->getCookie($this->secureSessionName));
    // Check insecure cookie is not set.     $this->assertFalse((bool) $this->getSession()->getCookie($this->insecureSessionName));
    $this->assertSessionIds($this->getSession()->getCookie($this->secureSessionName), 'Session has a non-empty SID and a correct secure SID.');
    $this->assertSessionIds($first_secure_session, 'The first secure session still exists.');

    
if ($this->isCSRFCookie()) {
            $cookie = config(CookieConfig::class);

            $this->configureCookie($cookie);
        } else {
            // Session based CSRF protection             $this->configureSession();
        }

        $this->request      = Services::request();
        $this->hashInCookie = $this->request->getCookie($this->cookieName);

        $this->restoreHash();
        if ($this->hash === null) {
            $this->generateHash();
        }
    }

    private function isCSRFCookie(): bool
    {
        return $this->config->csrfProtection === self::CSRF_PROTECTION_COOKIE;
    }

    
$auto = $this->defaultRouteService->findRouteValue($request, self::AUTO_NO_CACHE_CONTROLLERS);

        $tags = [];
        if (\is_array($auto)) {
            $tags = $auto;
        }

        if (!empty($this->session->offsetGet('sBasketQuantity')) || !empty($this->session->offsetGet('sNotesQuantity'))) {
            $tags[] = 'checkout';
        }

        if ($request->getCookie('slt')) {
            $tags[] = 'slt';
        }

        if (strtolower($request->getModuleName()) === 'frontend' && !empty($this->session->Admin)) {
            // Set admin-cookie if admin session is present             $tags[] = 'admin';
        }

        $action = $this->cacheRouteGeneration->getActionRoute($request);
        if ($action === 'frontend/account/logout') {
            $tags[] = '';
        }
// The front page defaults to 'user/login', which redirects to 'user/{user}'     // for authenticated users. We cannot use '<front>', since this does not     // match the redirected URL.     $frontpage_url = 'user/' . $this->adminUser->id();

    $this->drupalGet('admin/compact/on');
    $this->assertSession()->statusCodeEquals(200);
    // Verify that the user is redirected to the front page after turning on     // compact mode.     $this->assertSession()->addressEquals($frontpage_url);
    $this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns on.');
    $this->drupalGet('admin/compact/on');
    $this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode remains on after a repeat call.');
    $this->drupalGet('');
    $this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode persists on new requests.');

    $this->drupalGet('admin/compact/off');
    $this->assertSession()->statusCodeEquals(200);
    // Verify that the user is redirected to the front page after turning off     // compact mode.     $this->assertSession()->addressEquals($frontpage_url);
    $this->assertNull($session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns off.');
    
Home | Imprint | This part of the site doesn't use cookies.