PHPackages                             natilosir/cookie - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. natilosir/cookie

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

natilosir/cookie
================

A simple library for creating and managing cookies in PHP

1.0.1(1y ago)141MITPHP

Since Jan 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/natilosir/Cookie-php)[ Packagist](https://packagist.org/packages/natilosir/cookie)[ RSS](/packages/natilosir-cookie/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (1)

PHP Cookie Manager
==================

[](#php-cookie-manager)

Overview
--------

[](#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
------------

[](#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.

```
composer require natilosir/cookie
```

Usage
-----

[](#usage)

### Setting a Cookie

[](#setting-a-cookie)

To set a cookie, use the set method. You can specify the cookie name, value, and expiration time in days.

```
use natilosir\cookie\Cookie;

// Set a cookie
Cookie::set('username', 'JohnDoe', 7); // Expires in 7 days
```

### Getting a Cookie

[](#getting-a-cookie)

To retrieve the value of a cookie, use the get method.

```
// Get the cookie value
$username = Cookie::get('username');
echo 'Username: ' . $username; // Outputs: Username: JohnDoe
```

### Deleting a Cookie

[](#deleting-a-cookie)

To delete a cookie, use the delete method.

```
// Delete the cookie
Cookie::delete('username');
```

### Listing All Cookies

[](#listing-all-cookies)

To list all cookies available in the current session, use the list method.

```
// List all cookies
$allCookies = Cookie::list();
print_r($allCookies); // Outputs all cookies
```

Methods
-------

[](#methods)

### `set($name, $value, $days = 0)`

[](#setname-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)`

[](#getname)

Retrieves the value of the cookie with the specified name. Returns null if the cookie does not exist.

### `delete($name)`

[](#deletename)

Deletes the cookie with the specified name by setting its expiration date to a time in the past.

### `list()`

[](#list)

Returns an associative array of all cookies currently available in the $\_COOKIE superglobal.

Example
-------

[](#example)

Here is a complete example demonstrating how to use the PHP Cookie Manager:

```
use natilosir\cookie\Cookie;

// Set a cookie
Cookie::set('username', 'JohnDoe', 7);

// Get the cookie value
$username = Cookie::get('username');
echo 'Username: ' . $username; // Outputs: Username: JohnDoe

// Delete the cookie
Cookie::delete('username');

// List all cookies
$allCookies = Cookie::list();
print_r($allCookies); // Outputs all cookies
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance42

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

480d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab074f478dbfd74f8f693edecac575b69c1e42087aaa44343cc1b45c43c23059?d=identicon)[natilosir](/maintainers/natilosir)

### Embed Badge

![Health badge](/badges/natilosir-cookie/health.svg)

```
[![Health](https://phpackages.com/badges/natilosir-cookie/health.svg)](https://phpackages.com/packages/natilosir-cookie)
```

###  Alternatives

[magarrent/laravel-url-shortener

Simpler Url Shortener for Laravel

557.4k](/packages/magarrent-laravel-url-shortener)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
