PHPackages                             xety/cake3-cookieauth - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. xety/cake3-cookieauth

ActiveCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

xety/cake3-cookieauth
=====================

A simple Cake3 plugin to authenticate users with Cookies.

v1.4(9y ago)1956.6k↓74.8%12[4 issues](https://github.com/Xety/Cake3-CookieAuth/issues)[2 PRs](https://github.com/Xety/Cake3-CookieAuth/pulls)2MITPHPPHP &gt;=5.4.16

Since Nov 5Pushed 7y ago3 watchersCompare

[ Source](https://github.com/Xety/Cake3-CookieAuth)[ Packagist](https://packagist.org/packages/xety/cake3-cookieauth)[ Docs](https://github.com/Xety/Cake3-CookieAuth)[ RSS](/packages/xety-cake3-cookieauth/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (2)

Cake3 CookieAuth
================

[](#cake3-cookieauth)

A simple Cake3 plugin to authenticate users with Cookies. This plugin is based on the awesome plugin [FriendsOfCake/Authenticate](https://github.com/FriendsOfCake/Authenticate/tree/cake3) but with a different setup.

[![Build Status](https://camo.githubusercontent.com/816afc4a3e3f2a974b3ec97db62f091bea210ce838b7cf21cf84a93a6d458046/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f586574792f43616b65332d436f6f6b6965417574682e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Xety/Cake3-CookieAuth)[![Coverage Status](https://camo.githubusercontent.com/e4e8e1f868baaa375a4078f15cb9ddc446858e598aa9e37f99e9f70e1bb30507/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f586574792f43616b65332d436f6f6b6965417574682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/xety/Cake3-CookieAuth)[![Scrutinizer](https://camo.githubusercontent.com/78573133afd57e7b1f9685f388d1f554a366e2e85186c3f9f3eb16929efc2105/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f586574792f43616b65332d436f6f6b6965417574682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Xety/Cake3-CookieAuth)[![Latest Stable Version](https://camo.githubusercontent.com/155b2d1fcc444a9f5bb00ed78b3a24a0d00e6dc8ff93974780bdce5d0762712d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f586574792f43616b65332d436f6f6b6965417574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xety/cake3-cookieauth)[![Total Downloads](https://camo.githubusercontent.com/bfd5333c2d8b8fec3e640b24288f404945f822773ec53b6194ad00c931ab2c2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f786574792f63616b65332d636f6f6b6965617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xety/cake3-cookieauth)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xety/cake3-cookieauth)

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

[](#requirements)

- CakePHP 3.X

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

[](#installation)

Run : `composer require xety/cake3-cookieauth:1.*`Or add it in your `composer.json`:

```
"require": {
    "xety/cake3-cookieauth": "1.*"
},
```

Configuration
-------------

[](#configuration)

```
'Xety/Cake3CookieAuth.Cookie' => [
    'cookie' => [
        'name' => 'CookieAuth'
    ]
]
```

All others configuration option can be found on the official [CakePHP documentation](http://book.cakephp.org/3.0/en/controllers/components/authentication.html#configuring-authentication-handlers).

Usage
-----

[](#usage)

In your `config/bootstrap.php` add :

```
Plugin::load('Xety/Cake3CookieAuth');
```

In your `AppController` :

```
public $components = [
    'Cookie',
    'Auth' => [
        'authenticate' => [
            'Form',
            'Xety/Cake3CookieAuth.Cookie'
        ]
    ]

];
```

In your `AppController`, in the `beforeFilter` action :

```
public function beforeFilter(Event $event) {
    //Automaticaly Login.
    if (!$this->Auth->user() && $this->Cookie->read('CookieAuth')) {

        $user = $this->Auth->identify();
        if ($user) {
            $this->Auth->setUser($user);
        } else {
            $this->Cookie->delete('CookieAuth');
        }
    }
}

//If you want to update some fields, like the last_login_date, or last_login_ip, just do :
public function beforeFilter(Event $event) {
    //Automaticaly Login.
    if (!$this->Auth->user() && $this->Cookie->read('CookieAuth')) {
        $this->loadModel('Users');

        $user = $this->Auth->identify();
        if ($user) {
            $this->Auth->setUser($user);

            $user = $this->Users->newEntity($user);
            $user->isNew(false);

            //Last login date
            $user->last_login = new Time();
            //Last login IP
            $user->last_login_ip = $this->request->clientIp();
            //etc...

            $this->Users->save($user);
        } else {
            $this->Cookie->delete('CookieAuth');
        }
    }
}
```

In your `login` action, after `$this->Auth->setUser($user);` :

```
//It will write Cookie without RememberMe checkbox
$this->Cookie->configKey('CookieAuth', [
    'expires' => '+1 year',
    'httpOnly' => true
]);
$this->Cookie->write('CookieAuth', [
    'username' => $this->request->data('username'),
    'password' => $this->request->data('password')
]);

//If you want use a RememberMe checkbox in your form :
//In your view
echo $this->Form->checkbox('remember_me');

//In the login action :
if($this->request->data('remember_me')) {
    $this->Cookie->configKey('CookieAuth', [
        'expires' => '+1 year',
        'httpOnly' => true
    ]);
    $this->Cookie->write('CookieAuth', [
        'username' => $this->request->data('username'),
        'password' => $this->request->data('password')
    ]);
}
```

Contribute
----------

[](#contribute)

[Follow this guide to contribute](https://github.com/Xety/Cake3-CookieAuth/blob/master/CONTRIBUTING.md)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 81.8% 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 ~180 days

Total

5

Last Release

3539d ago

PHP version history (2 changes)v1.0PHP &gt;=5.4.0

v1.3PHP &gt;=5.4.16

### Community

Maintainers

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

---

Top Contributors

[![Xety](https://avatars.githubusercontent.com/u/8210023?v=4)](https://github.com/Xety "Xety (9 commits)")[![antograssiot](https://avatars.githubusercontent.com/u/4977112?v=4)](https://github.com/antograssiot "antograssiot (1 commits)")[![icaroscherma](https://avatars.githubusercontent.com/u/42467?v=4)](https://github.com/icaroscherma "icaroscherma (1 commits)")

---

Tags

pluginauthcakephplogincookieauthenticatecake3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xety-cake3-cookieauth/health.svg)

```
[![Health](https://phpackages.com/badges/xety-cake3-cookieauth/health.svg)](https://phpackages.com/packages/xety-cake3-cookieauth)
```

###  Alternatives

[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

131240.2k13](/packages/dereuromark-cakephp-tinyauth)[cakedc/users

Users Plugin for CakePHP

525928.0k20](/packages/cakedc-users)[dereuromark/cakephp-setup

A CakePHP plugin containing lots of useful management tools

36199.6k2](/packages/dereuromark-cakephp-setup)[andrej-griniuk/cakephp-two-factor-auth

CakePHP auth component and provider fot two-factor authentication

38110.9k](/packages/andrej-griniuk-cakephp-two-factor-auth)[ivanamat/cakephp3-aclmanager

AclManager plugin for CakePHP 3.x

2715.8k2](/packages/ivanamat-cakephp3-aclmanager)

PHPackages © 2026

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