Download the PHP package natilosir/cookie without Composer
On this page you can find all versions of the php package natilosir/cookie. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download natilosir/cookie
More information about natilosir/cookie
Files in natilosir/cookie
Package cookie
Short Description A simple library for creating and managing cookies in PHP
License MIT
Informations about the package cookie
PHP Cookie Manager
Overview
The PHP Cookie Manager is a simple and effective class for managing cookies in PHP applications. This class provides static methods to set, get, delete, and list cookies easily, allowing for straightforward cookie management without the need for instantiation.
Installation
To use the PHP Cookie Manager in your project, simply include the Cookie.php file in your project. You can also install it via Composer.
Usage
Setting a Cookie
To set a cookie, use the set method. You can specify the cookie name, value, and expiration time in days.
Getting a Cookie
To retrieve the value of a cookie, use the get method.
Deleting a Cookie
To delete a cookie, use the delete method.
Listing All Cookies
To list all cookies available in the current session, use the list method.
Methods
set($name, $value, $days = 0)
Sets a cookie with the specified name and value. If $days is greater than 0, the cookie will expire after the specified number of days.
get($name)
Retrieves the value of the cookie with the specified name. Returns null if the cookie does not exist.
delete($name)
Deletes the cookie with the specified name by setting its expiration date to a time in the past.
list()
Returns an associative array of all cookies currently available in the $_COOKIE superglobal.
Example
Here is a complete example demonstrating how to use the PHP Cookie Manager: