PHPackages                             renanluis/cookie-parser - 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. renanluis/cookie-parser

ActiveLibrary

renanluis/cookie-parser
=======================

A small library to parse cookies data.

v1.0.0(5y ago)025GPL-3.0PHPPHP &gt;=7.4

Since Feb 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/renanluis/cookie-parser)[ Packagist](https://packagist.org/packages/renanluis/cookie-parser)[ RSS](/packages/renanluis-cookie-parser/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Cookie Parser
=============

[](#cookie-parser)

This library could be used to get all cookies in a header string of a HTTP request and return it as an array or cookie string.

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

[](#installation)

The preferred method of installation is via [Composer](http://getcomposer.org/). Run the following command to install the latest version of a package and add it to your project's `composer.json`:

```
composer require renanluis/cookie-parser
```

Example
-------

[](#example)

**Convert a String of cookies to Array or vice versa**

```
use CookieParser\CookieParser;
$cookieString = 'user=test; token=Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa';
$CookieParser = new CookieParser($cookieString);
var_dump($CookieParser->toArray());
/*
array(2) {
  ["user"]=>
  string(4) "test"
  ["token"]=>
  string(35) "Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa"
}
*/
var_dump($CookieParser->toString());
/*
string(52) "user=test; token=Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa"
*/
```

```
use CookieParser\CookieParser;
$cookieArray = array('user' => 'test', 'token' => 'Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa');
$CookieParser = new CookieParser($cookieArray);
var_dump($CookieParser->toString());
/*
string(52) "user=test; token=Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa"
*/
var_dump($CookieParser->toArray());
/*
array(2) {
  ["user"]=>
  string(4) "test"
  ["token"]=>
  string(35) "Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa"
}
*/
```

**Get cookies from HTTP Headers string**

```
use CookieParser\CookieParser;
$headers = 'HTTP 1/1 200 OK
set-cookie: user=test; path=/; expires=Wed, 03 Mar 2021 01:10:47 GMT; secure; HttpOnly; SameSite=Lax
set-cookie: token=Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa; path=/; expires=Wed, 03 Mar 2021 01:10:47 GMT; secure; HttpOnly; SameSite=Lax';
$CookieParser = new CookieParser();
var_dump($CookieParser->getFromHeaders($headers));
/*
string(52) "user=test; token=Qf9qbOKsrxfBhUSjFUyCS9zxKhMjdINa"
*/
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

1911d ago

### Community

Maintainers

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

---

Top Contributors

[![renanluis](https://avatars.githubusercontent.com/u/17876224?v=4)](https://github.com/renanluis "renanluis (23 commits)")

### Embed Badge

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

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

PHPackages © 2026

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