PHP code example of antikirra / cookies-builder

1. Go to this page and download the library: Download antikirra/cookies-builder 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/ */

    

antikirra / cookies-builder example snippets




declare(strict_types=1);

use Antikirra\Cookies\Builder;

EdrAP4');

// `__toString()` same as `->build()`
echo $builder
    ->expires((new DateTimeImmutable())->modify('+1 year'))
    ->build();

// token=xaz8BXsTr2XGF9FYc3ckaeKpeyEdrAP4; Path=/; Expires=Tue, 04 Feb 2025 00:00:00 GMT; Secure; HttpOnly

$builder = Builder::remove('token');

echo $builder->build();

// token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure; HttpOnly