PHPackages                             miladrahimi/phpcookie - 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. [Security](/categories/security)
4. /
5. miladrahimi/phpcookie

AbandonedArchivedLibrary[Security](/categories/security)

miladrahimi/phpcookie
=====================

Free PHP cookie tools for neat and powerful projects!

1.5(10y ago)6701MITPHPPHP &gt;=5.3.0

Since Jun 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/miladrahimi/phpcookie)[ Packagist](https://packagist.org/packages/miladrahimi/phpcookie)[ Docs](http://miladrahimi.github.io/phpcookie)[ RSS](/packages/miladrahimi-phpcookie/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

PHPCookie
=========

[](#phpcookie)

Free PHP cookie tools for neat and powerful projects!

Documentation
-------------

[](#documentation)

PHPCookie is a tiny package for working with cookies and encrypting them. It implemented the easy way to access and manipulating cookies with assuming security issues. This package uses [PHPCrypt](https://github.com/miladrahimi/phpcrypt) package for encryption.

### Installation

[](#installation)

#### Using Composer

[](#using-composer)

It's strongly recommended to use [Composer](http://getcomposer.org). If you are not familiar with Composer, The article [How to use composer in php projects](http://miladrahimi.com/blog/2015/04/12/how-to-use-composer-in-php-projects)can be useful. After installing Composer, go to your project root directory and run following command there:

```
composer require miladrahimi/phpcookie

```

Or if you have `composer.json` file already in your application, you may add this package to your application requirements and update your dependencies:

```
"require": {
    "miladrahimi/phpcookie": "~1.5"
}

```

```
composer update

```

#### Manually

[](#manually)

You can use your own autoloader as long as it follows [PSR-0](http://www.php-fig.org/psr/psr-0) or [PSR-4](http://www.php-fig.org/psr/psr-4) standards. In this case you can put `src` directory content in your vendor directory.

### Getting Started

[](#getting-started)

It's so easy to use! It uses [PHPCrypt](https://github.com/miladrahimi/phpcrypt) package to encrypt and decrypt data. So if you use Composer everything will be ok otherwise you must download this package too. After installation of this package you must inject it to Cookie class. See the example to grasp all what you need to know:

```
use MiladRahimi\PHPCookie\Cookie;
use MiladRahimi\PHPCrypt\Crypt;

$project_key = "3303a3f4640d601566c02cb8fe16d96e";

$crypt = new Crypt();
$crypt->setKey($project_key);

$cookie = new Cookie();
$cookie->setCrypt($crypt);

$cookie->set("Singer", "Pink Floyd");

```

- First of all, you must set your project key to the instance of `Crypt` class.
- Second of all, you must inject Crypt object to `Cookie` class via `Cookie::setCrypt()` method.
- You can use `Cookie::set()` and `Cookie::get()` to set and get data in cookies.
- The `Cookie::set()` parameters matches with native PHP `setCookie` function.

### Getting data from cookies

[](#getting-data-from-cookies)

There is `get()` method in `Cookie` class which you can use to get data from cookie.

```
echo $cookie->get("Singer");

```

### Encryption

[](#encryption)

All cookies will be encrypted. If you set cookie via this package, you have to use this package to get it too.

### PHPCookieException

[](#phpcookieexception)

There are some situation which PHPCookieException will be thrown. Here are methods and messages:

- `Crypt object is not set` in `Cookie::set()` when you use this method before injecting Crypt instance to the class.
- `Crypt object is not set` in `Cookie::get()` when you use this method before injecting Crypt instance to the class.
- `The cookie value not exists` in `Cookie::get()` when you trying to get some cookie value which not exists.

Contributors
------------

[](#contributors)

- [Milad Rahimi](http://miladrahimi.com)

Homepage
--------

[](#homepage)

- [PHPCookie](http://miladrahimi.github.io/phpcookie)

License
-------

[](#license)

PHPCookie is released under the [MIT License](http://opensource.org/licenses/mit-license.php).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

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

Total

6

Last Release

3949d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/921274b8bb29236d8f94f6c83100a5f751f6394c4c49741e1b92bfbccac0911b?d=identicon)[miladrahimi](/maintainers/miladrahimi)

---

Top Contributors

[![miladrahimi](https://avatars.githubusercontent.com/u/6689295?v=4)](https://github.com/miladrahimi "miladrahimi (15 commits)")

---

Tags

securitycookiescookieCookie Security

### Embed Badge

![Health badge](/badges/miladrahimi-phpcookie/health.svg)

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

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41478.1M118](/packages/robrichards-xmlseclibs)[voku/anti-xss

anti xss-library

72317.1M77](/packages/voku-anti-xss)[spatie/laravel-csp

Add CSP headers to the responses of a Laravel app

8569.6M19](/packages/spatie-laravel-csp)

PHPackages © 2026

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