PHP code example of 00f100 / fcphp-cookie

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

    

00f100 / fcphp-cookie example snippets



use FcPhp\Cookie\Facades\CookieFacade;

/**
 * Facade to return instance of Cookie
 * 
 * @param string $key Key into $_COOKIE of Cookie
 * @param array $cookies Variable $_SESSION
 * @param string $nonce Nonce to Crypto
 * @param string $pathKeys Path to save keys of Crypto
 * @param string $forceNewInstance Force create new instance
 * @return FcPhp\Cookie\Interfaces\ICookie
 */
CookieFacade::getInstance(string $key, array $cookies, string $nonce = null, string $pathKeys = null, bool $forceNewInstance = false) :ICookie

// With No Crypto into content
$cookie = CookieFacade::getInstance('key-cookie', $_COOKIE);

// With Crypto into content
use FcPhp\Crypto\Crypto;
$nonce = Crypto::getNonce();
$cookie = CookieFacade::getInstance('key-cookie', $_COOKIE, $nonce);

// Create new configuration
$cookie->set('item.config', 'value');

// Print: value
echo $cookie->get('item.config');