1. Go to this page and download the library: Download buzzingpixel/cookie-api 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/ */
buzzingpixel / cookie-api example snippets
declare(strict_types=1);
use corbomite\di\Di;
use buzzingpixel\cookieapi\CookieApi;
/** @var CookieApi $cookieApi */
$cookieApi = Di::get('CookieApi');
// Make a cookie entity (same as new \buzzingpixel\cookieapi\Cookie) but more testable as method call
$cookie = $cookieApi->makeCookie('MyCookie', 'MyValue');
$newCookie = $cookie->withValue('myNewValue');
declare(strict_types=1);
use corbomite\di\Di;
use buzzingpixel\cookieapi\CookieApi;
/** @var CookieApi $cookieApi */
$cookieApi = Di::get('CookieApi');
// Get a cookie by its name. Returns a `\buzzingpixel\cookieapi\Cookie` entity or null if no cookie by that name is set
$cookie = $cookieApi->retrieveCookie('MyCookie');
declare(strict_types=1);
use corbomite\di\Di;
use buzzingpixel\cookieapi\CookieApi;
/** @var CookieApi $cookieApi */
$cookieApi = Di::get('CookieApi');
$cookie = $cookieApi->makeCookie('MyCookie', 'MyValue');
$cookieApi->saveCookie($cookie);
declare(strict_types=1);
use corbomite\di\Di;
use buzzingpixel\cookieapi\CookieApi;
/** @var CookieApi $cookieApi */
$cookieApi = Di::get('CookieApi');
// Delete a cookie by passing the cookie entity to be deleted
$cookie = $cookieApi->retrieveCookie('MyCookie');
$cookieApi->deleteCookie($cookie);
// Delete a cookie by name
$cookieApi->deleteCookieByName('MyCookie');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.