PHP code example of ezeasorekene / php-cookie-manager
1. Go to this page and download the library: Download ezeasorekene/php-cookie-manager 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/ */
ezeasorekene / php-cookie-manager example snippets
// Get the value of a cookie
$username = Cookie::get('username');
// Set a cookie with custom options
Cookie::set('user_id', 123, ['expires' => time() + 3600, 'secure' => true]);
// Check if a cookie exists
if (Cookie::has('token')) {
// Perform an action
}
// Destroy a cookie
Cookie::destroy('session_id');
get($name)
Get the value of a cookie.
set($name, $value, $options = [])
Set a cookie.
setMultiple($cookies, $options = [])
Set multiple cookies.
has($name)
Check if a cookie exists.
destroy($name, $options = [])
Destroy a cookie.
destroyMultiple($cookies, $options = [])
Destroy multiple cookies.
jsonSet($name, $value, $options = [])
Set a JSON-encoded cookie.
jsonGet($name, $assoc = false)
Get the JSON-decoded value of a cookie.
jsonHas($name)
Check if a JSON-encoded cookie exists.
jsonDestroy($name, $options = [])
Destroy a JSON-encoded cookie.
jsonDestroyMultiple($cookies, $options = [])
Destroy multiple JSON-encoded cookies.
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.