00f100/fcphp-cookie

There is no license information available for the latest version (0.1.2) of this package.

Package to manipulate Cookies

0.1.2 2018-08-04 15:46 UTC

This package is auto-updated.

Last update: 2024-11-18 06:22:45 UTC


README

Package to manipulate Cookie

Build Status codecov Total Downloads

How to install

Composer:

$ composer require 00f100/fcphp-cookie

or add in composer.json

{
    "require": {
        "00f100/fcphp-cookie": "*"
    }
}

How to use

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');