PHP code example of constanze-standard / cookies

1. Go to this page and download the library: Download constanze-standard/cookies library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

constanze-standard / cookies example snippets


use ConstanzeStandard\Cookies\Cookie;
use ConstanzeStandard\Cookies\CookieCollection;

$cookie = new Cookie('name', 'value', 60);

$cookieCollection = new CookieCollection();
$cookieCollection->addCookie($cookie);

use ConstanzeStandard\Cookies\CookieCollection;

$cookieCollection = new CookieCollection();
/** @var \ConstanzeStandard\Cookies\Cookie $cookie */
$cookie = $cookieCollection->add('name', 'value', 60);

$cookieCollection = new CookieCollection('localhost', true);

/**
 * @var \Psr\Http\Message\ResponseInterface $response
 * @var \Psr\Http\Message\ResponseInterface $newResponse
 */
$newResponse = $cookieCollection->makeResponse($response);