PHPackages                             bayfrontmedia/php-cookies - 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. bayfrontmedia/php-cookies

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

bayfrontmedia/php-cookies
=========================

Helper class to easily work with cookies.

v2.1.0(4mo ago)21.2k3MITPHPPHP ^8.0

Since Jul 27Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/bayfrontmedia/php-cookies)[ Packagist](https://packagist.org/packages/bayfrontmedia/php-cookies)[ Docs](https://github.com/bayfrontmedia/php-cookies)[ RSS](/packages/bayfrontmedia-php-cookies/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (7)DependenciesVersions (8)Used By (3)

PHP cookies
-----------

[](#php-cookies)

Helper class to easily and safely work with cookies.

- [License](#license)
- [Author](#author)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)

License
-------

[](#license)

This project is open source and available under the [MIT License](LICENSE).

Author
------

[](#author)

[![Bayfront Media](https://camo.githubusercontent.com/0c0163913b2092e97dbf9684970adaf86f2f25871298d3d28b2dff4bf75b2915/68747470733a2f2f63646e312e6f6e62617966726f6e742e636f6d2f62666d2f6272616e642f62666d2d6c6f676f2e737667)](https://camo.githubusercontent.com/0c0163913b2092e97dbf9684970adaf86f2f25871298d3d28b2dff4bf75b2915/68747470733a2f2f63646e312e6f6e62617966726f6e742e636f6d2f62666d2f6272616e642f62666d2d6c6f676f2e737667)

- [Bayfront Media homepage](https://www.bayfrontmedia.com?utm_source=github&utm_medium=direct)
- [Bayfront Media GitHub](https://github.com/bayfrontmedia)

Requirements
------------

[](#requirements)

- PHP `^8.0` (Tested up to `8.4`)

Installation
------------

[](#installation)

```
composer require bayfrontmedia/php-cookies

```

Usage
-----

[](#usage)

- [get](#get)
- [has](#has)
- [set](#set)
- [forget](#forget)
- [forgetAll](#forgetall)

---

### get

[](#get)

**Description:**

Returns value of single `$_COOKIE` array key or entire array, with optional default value.

**Parameters:**

- `$key = NULL` (string|null)
- `$default = NULL` (mixed): Default value to return if the array key is not found

**Returns:**

- (mixed)

**Example:**

```
use Bayfront\Cookies\Cookie;

print_r(Cookie::get());

```

---

### has

[](#has)

**Description:**

Checks if `$_COOKIE` array key exists.

**Parameters:**

- `$key` (string)

**Returns:**

- (bool)

**Example:**

```
use Bayfront\Cookies\Cookie;

if (Cookie::has('cart_id')) {
    // Do something
}

```

---

### set

[](#set)

**Description:**

Creates a cookie.

See:

**Parameters:**

- `$name` (string): Cookie name
- `$value` (string): Cookie value
- `$minutes = 0` (int): Minutes from now until the cookie expires
- `$path = '/'` (string): Path on the server in which the cookie will be available
- `$domain = ''` (string): Domain/subdomain that the cookie is available to
- `$secure = true` (bool): Transmit the cookie only over a secure https connection
- `$http_only = true` (bool): Accessible only through the http protocol
- `$same_site = 'Lax'` (string): Acceptable values of `None`, `Lax` or `Strict`

**Returns:**

- (bool)

**Example:**

```
use Bayfront\Cookies\Cookie;

Cookie::set('cart_id', 'abc123', 60);

```

---

### forget

[](#forget)

**Description:**

Removes validity of cookie.

**Parameters:**

- `$name` (string)
- `$path = '/'` (string): Path on the server for the cookie to be removed
- `$domain = ''` (string): Same value that the cookie was set with
- `$secure = true` (bool): Same value that the cookie was set with
- `$http_only = true` (bool): Same value that the cookie was set with
- `$same_site = 'Lax'` (string): Same value that the cookie was set with. Acceptable values of `None`, `Lax` or `Strict`

**Returns:**

- (void)

**Example:**

```
use Bayfront\Cookies\Cookie;

Cookie::forget('cart_id');

```

---

### forgetAll

[](#forgetall)

**Description:**

Removes the validity of all cookies.

NOTE: This will not delete cookies set with custom path, domain, secure, http\_only or same\_site.

**Parameters:**

- None

**Returns:**

- (void)

**Example:**

```
use Bayfront\Cookies\Cookie;

Cookie::forgetAll();

```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance76

Regular maintenance activity

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~332 days

Recently: every ~439 days

Total

7

Last Release

129d ago

Major Versions

v1.1.0 → v2.0.02023-01-26

PHP version history (3 changes)1.0.0PHP &gt;=7.1.0

v1.1.0PHP &gt;=7.3.0

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ad62c8d0e69358fd63b16fdaa71d5359231cd0cf660bbc3419071dc705c63a8?d=identicon)[bayfrontmedia](/maintainers/bayfrontmedia)

---

Top Contributors

[![robinsonjohn](https://avatars.githubusercontent.com/u/24327848?v=4)](https://github.com/robinsonjohn "robinsonjohn (13 commits)")

---

Tags

cookiecookiesphpphpcookiescookie

### Embed Badge

![Health badge](/badges/bayfrontmedia-php-cookies/health.svg)

```
[![Health](https://phpackages.com/badges/bayfrontmedia-php-cookies/health.svg)](https://phpackages.com/packages/bayfrontmedia-php-cookies)
```

###  Alternatives

[josantonius/cookie

PHP library for handling cookies.

2238.7k4](/packages/josantonius-cookie)[marcogermani87/filament-cookie-consent

Easy cookie consent integrations for Filament

1917.0k](/packages/marcogermani87-filament-cookie-consent)

PHPackages © 2026

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