PHP code example of muhammetsafak / secret-cookies

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

    

muhammetsafak / secret-cookies example snippets


$options = [
        'algo'      => 'SHA256', // String : OpenSSL Algorithm
        'cipher'    => 'AES-256-CTR', // String : OpenSSL Cipher
        'key'       => 'SecretCookie', // String : Top Secret Key
        'ttl'       => 3600, // Integer : Seconds - LifeTime
        'path'      => '/', // String
        'domain'    => null, // Null or String. If it is empty, it is not used.
        'secure'    => false, // Boolean
        'httponly'  => true, // Boolean
        'samesite'  => 'Strict', // "None", "Lax" or "Strict"
];


use MuhammetSafak\SecretCookies\Segment;

// See the configuration section for detailed information.
$options = [];

$cookie = new Segment('cookieName', $options);

$cookie->set('username', 'muhammetsafak')
        ->set('mail', '[email protected]');

public function has(string $key): bool;

public function get(string $key, $default = null): mixed;

public function set(string $key, $value): self;

public function remove(string $key): self;

public function save(): void;

public function getDebug(): string[];