PHPackages                             guilherme/konf-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. [HTTP &amp; Networking](/categories/http)
4. /
5. guilherme/konf-cookie

ActiveLibrary[HTTP &amp; Networking](/categories/http)

guilherme/konf-cookie
=====================

A library manager cookie

1.0.3(1y ago)02MITPHP

Since Apr 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Guilherme-fagundes/konf-cookie)[ Packagist](https://packagist.org/packages/guilherme/konf-cookie)[ RSS](/packages/guilherme-konf-cookie/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

KonfCookie
==========

[](#konfcookie)

**KonfCookie** is a simple and secure PHP class for managing HTTP cookies. It allows setting, getting, checking existence, deleting cookies, and retrieving all cookies in a straightforward manner.

Features
--------

[](#features)

- Set cookies with optional expiration, path, domain, secure flag, and HttpOnly flag.
- Retrieve cookies easily.
- Check if a cookie exists.
- Delete cookies.
- Retrieve all cookies in one go.

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

[](#installation)

You can install **KonfCookie** using **Composer**.

### Using Composer

[](#using-composer)

To install the package, run the following command:

```
composer require guilherme/konfcookie
```

Usage
-----

[](#usage)

### 1. Creating a Cookie Object

[](#1-creating-a-cookie-object)

You can instantiate the `Cookie` class without any parameters.

```
use Guilherme\KonfCookie\Cookie;

$cookie = new Cookie();
```

### 2. Setting a Cookie

[](#2-setting-a-cookie)

To set a cookie, use the `set()` method. Below are examples of how to set cookies with and without additional parameters.

#### Example 1: Setting a Simple Cookie

[](#example-1-setting-a-simple-cookie)

```
// Set a cookie that expires in 1 hour
$cookie->set('user', 'john_doe', 3600);
```

#### Example 2: Setting a Cookie with Optional Parameters

[](#example-2-setting-a-cookie-with-optional-parameters)

```
$cookie->set(
    'user',      // Cookie name
    'john_doe',  // Cookie value
    3600,        // Expiration in seconds
    '/',         // Path
    '',          // Domain
    true,        // Secure (HTTPS only)
    true         // HttpOnly (not accessible by JavaScript)
);
```

#### Parameters:

[](#parameters)

- `$name` (string): The name of the cookie.
- `$value` (string): The value to store in the cookie.
- `$expire` (int): Expiration time in seconds (0 means session cookie).
- `$path` (string): Path where the cookie is accessible.
- `$domain` (string): Domain for which the cookie is valid.
- `$secure` (bool): Whether the cookie should only be sent over HTTPS.
- `$httponly` (bool): Whether the cookie should be accessible only through HTTP.

### 3. Getting a Cookie Value

[](#3-getting-a-cookie-value)

```
$user = $cookie->get('user');
echo $user; // Outputs: john_doe
```

### 4. Checking if a Cookie Exists

[](#4-checking-if-a-cookie-exists)

```
if ($cookie->exists('user')) {
    echo "Cookie 'user' exists!";
} else {
    echo "Cookie 'user' does not exist!";
}
```

### 5. Deleting a Cookie

[](#5-deleting-a-cookie)

```
$cookie->destroy('user'); // Simple deletion
```

```
// Deleting with custom options
$cookie->destroy('user', '/', '', true, true);
```

### 6. Retrieving All Cookies

[](#6-retrieving-all-cookies)

```
$allCookies = $cookie->getAll();
print_r($allCookies);
```

### Full Example

[](#full-example)

```
use Guilherme\KonfCookie\Cookie;

$cookie = new Cookie();

// Set a cookie
$cookie->set('user', 'john_doe', 3600);

// Get a cookie
echo $cookie->get('user');

// Check if it exists
if ($cookie->exists('user')) {
    echo "Exists!";
}

// List all cookies
print_r($cookie->getAll());

// Delete it
$cookie->destroy('user');
```

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.

Contributing
------------

[](#contributing)

Contributions are welcome! Fork the repository, create a branch, and submit a pull request. For bugs or suggestions, open an issue.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance48

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

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

Total

4

Last Release

384d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca237ea3fe636e6f5131c4d01aaffb406518ddf35c2707184603e3c114c14d70?d=identicon)[Guilherme Fagundes](/maintainers/Guilherme%20Fagundes)

---

Top Contributors

[![guilhermekfagundes](https://avatars.githubusercontent.com/u/21370210?v=4)](https://github.com/guilhermekfagundes "guilhermekfagundes (7 commits)")

---

Tags

httpphpbrowsermanagersessioncookiekonfcookie

### Embed Badge

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

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

###  Alternatives

[codezero/laravel-localizer

Automatically detect and set an app locale that matches your visitor's preference.

50394.3k4](/packages/codezero-laravel-localizer)[hannesvdvreken/guzzle-debugbar

A Guzzle middleware that logs requests to debugbar's timeline

76410.4k1](/packages/hannesvdvreken-guzzle-debugbar)

PHPackages © 2026

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