1. Go to this page and download the library: Download elephpant/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/ */
elephpant / cookie example snippets
use ElePHPant\Cookie\Cookie\Cookie;
// default expiration: minutes
// default encryption: there is no encryption
$cookie = new Cookie();
// change expiration unit
$options = [
'expiration' => 'days', // seconds, minutes, hours, days, weeks, months, years
];
// set Base64 encryption
$options = [
'encryption' => \ElePHPant\Cookie\Strategies\Encryption\Base64EncryptionStrategy::class,
];
// set AES-256 encryption
$options = [
'encryption' => \ElePHPant\Cookie\Strategies\Encryption\AES256EncryptionStrategy::class,
'encrypt_key' => 'SET_YOUR_ENCRYPT_KEY_HERE', //
$cookie::destroy('user');
$cookie::destroy(); // all
if ($cookie::has('food')) {
echo 'The cookie exists.';
} else {
echo 'The cookie does not exist.';
}
if ($cookie::has('username', $str)) {
echo 'The cookie exists with the correct value.';
} else {
echo 'The cookie does not exist or has a different value.';
}
if ($cookie::has('user', $arr)) {
echo 'The cookie exists with the correct value.';
} else {
echo 'The cookie does not exist or has a different value.';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.