This class provides methods to manage cookies in PHP applications.
This PHP class provides convenient methods to manage cookies in web applications.
You can install this package using Composer:
composer require ezeasorekene/php-cookie-manager
// 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.
If you'd like to contribute, please fork the repository and make your changes. Pull requests are warmly welcome.
This package is licensed under the MIT License.
For inquiries, please email me at ezeasorekene@gmail.com
© 2023 Ezeasor Ekene. All rights reserved.