1. Go to this page and download the library: Download refkinscallv/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/ */
refkinscallv / cookie example snippets
use RF\Cookie\Cookie;
// Initialize Cookie class without encryption
$cookie = new Cookie();
// Set a cookie
$cookie->set('user', 'John Doe');
// Get a cookie value
echo $cookie->get('user'); // Outputs: John Doe
// Check if a cookie exists
if ($cookie->has('user')) {
echo 'User cookie is set.';
}
// Unset a cookie
$cookie->unset('user');
// Destroy all cookies
$cookie->destroy();
use RF\Crypto\Crypto;
use RF\Cookie\Cookie;
// Instantiate the Crypto class
$crypto = new Crypto([
"encryptKey" => "your-secret-key",
"encryptCipher" => "AES-256-CBC",
"encryptStoreMethod" => "local",
"encryptFile" => "/path/to/encrypt.txt"
]);
// Initialize Cookie class with encryption
$cookie = new Cookie($crypto);
// Set an encrypted cookie
$cookie->set('user', 'John Doe');
// Get an encrypted cookie value
echo $cookie->get('user'); // Outputs: John Doe
// Check if a cookie exists
if ($cookie->has('user')) {
echo 'User cookie is set.';
}
// Unset an encrypted cookie
$cookie->unset('user');
// Destroy all encrypted cookies
$cookie->destroy();
use RF\Crypto\Crypto;
use RF\Cookie\Cookie;
// Configure Crypto with database storage
$crypto = new Crypto([
"encryptKey" => "your-secret-key",
"encryptCipher" => "AES-256-CBC",
"encryptStoreMethod" => "database",
"encryptDBHandler" => function($data, $mode) {
// Database logic for storing and retrieving encrypted data
if ($mode === 'save') {
// Save $data to the database
} elseif ($mode === 'load') {
// Retrieve and return encrypted data from the database
}
}
]);
// Initialize Cookie class with database encryption
$cookie = new Cookie($crypto);
// Set and retrieve an encrypted cookie
$cookie->set('user', 'Encrypted User');
echo $cookie->get('user'); // Outputs: Encrypted User
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.