PHP code example of marcoschwepp / cookie-manager

1. Go to this page and download the library: Download marcoschwepp/cookie-manager 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/ */

    

marcoschwepp / cookie-manager example snippets


// only the name is schwepp\Cookie\Cookie('testCookie');

// optional parameters: 
$cookie->setValue('123456');
$cookie->setExpiresAt(new \DateTimeImmutable()) // e.g. timestamp now + 24h = \time() + 86400
$cookie->setPath('/');
$cookie->setDomain('.local.de');
$cookie->setSecure(false);
$cookie->setHttpOnly(false);

$options = [
    'name' => 'Test-Cookie',
    'value' => 'Test-Value',
    'expiresAt' => new \DateTimeImmutable,
    'path' => '/',
    'domain' => 'local.de',
    'secure' => true,
    'httpOnly' => true,
];

$cookie = marcoschwepp\Cookie\Cookie::constructFromOptions($options);

$cookie->save();
$cookie->delete('testCookie');
$cookie->load();