PHPackages                             gomes81/guzzlehttp-cookie-auth-subscriber - 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. gomes81/guzzlehttp-cookie-auth-subscriber

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

gomes81/guzzlehttp-cookie-auth-subscriber
=========================================

Guzzle Cookie Auth subscriber

0.3.0(4y ago)119711MITPHPPHP &gt;=5.5.0CI failing

Since Jan 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Gomes81/guzzlehttp-cookie-auth-subscriber)[ Packagist](https://packagist.org/packages/gomes81/guzzlehttp-cookie-auth-subscriber)[ Docs](https://github.com/gomes81/guzzlehttp-cookie-auth-subscriber/)[ RSS](/packages/gomes81-guzzlehttp-cookie-auth-subscriber/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)Dependencies (2)Versions (9)Used By (1)

Guzzle CookieAuth Subscriber
============================

[](#guzzle-cookieauth-subscriber)

Signs HTTP requests using cookies. Requests are signed using a login form, containing a username and password (and / or any other fields you wish to include). The credentials are then send to the provided url using the specified HTTP method (usually POST) and the returned cookies are saved for later use.

This version only works with Guzzle 6.0 and up!

Installing
----------

[](#installing)

This project can be installed using Composer. Add the following to your composer.json:

```
{
    "require": {
        "gomes81/guzzlehttp-cookie-auth-subscriber": "0.1.*"
    }
}
```

Using the Subscriber
--------------------

[](#using-the-subscriber)

Here's an example showing how to send an authenticated request:

```
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Gomes81\GuzzleHttp\Subscriber\CookieAuth;

$stack = HandlerStack::create();

$middleware = new CookieAuth(
    '/login_simple_url_or_path',
    [
        'username'    => 'my_username',
        'password'    => 'my_password',
        'other_field' => 'my_field_value'
    ],
    'POST',// GET, POST or JSON (will JSON encode fields array and send it inside the POST request body)
    'you can also pass a cookie string to use in here');
$stack->push($middleware);

$client = new Client([
    'base_uri' => 'http://simple_url.com',
    'handler'  => $stack
]);

// Set the "auth" request option to "cookie" to sign the request using a cookie
// Before calling the given url the subscriber will check if there's a valid cookie
// to be injected in the current request, if a valid cookie could not be found an
// additional request is made to obtain it
$res = $client->get('statuses/home_timeline.json', ['auth' => 'cookie']);
```

You can set the `auth` request option to `cookie` for all requests sent by the client by extending the array you feed to `new Client` with auth =&gt; cookie.

```
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Gomes81\GuzzleHttp\Subscriber\CookieAuth;

$stack = HandlerStack::create();

$middleware = new CookieAuth(
    '/login_simple_url_or_path', [
        'username'    => 'my_username',
        'password'    => 'my_password',
        'other_field' => 'my_field_value'],
    'POST',// GET, POST or JSON (will JSON encode fields array and send it inside the POST request body)
    'you can also pass a cookie string to use in here');
$stack->push($middleware);

$client = new Client([
    'base_uri' => 'http://simple_url.com',
    'handler'  => $stack,
    'auth'     => 'cookie'
]);

// Now you don't need to add the auth parameter
$res = $client->get('statuses/home_timeline.json');
```

You can also save cookies to a file by passing a FileCookieJar object instance in the forth parameter.

```
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Cookie\FileCookieJar;
use Gomes81\GuzzleHttp\Subscriber\CookieAuth;

$stack = HandlerStack::create();

$middleware = new CookieAuth(
    '/login_simple_url_or_path', [
        'username'    => 'my_username',
        'password'    => 'my_password',
        'other_field' => 'my_field_value'],
    'POST',// GET, POST or JSON (will JSON encode fields array and send it inside the POST request body)
    new FileCookieJar('./cookies_folder/cookie_file_name', true));
$stack->push($middleware);
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

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

Recently: every ~567 days

Total

6

Last Release

1497d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/585107?v=4)[Diogo Gomes](/maintainers/Gomes)[@gomes](https://github.com/gomes)

---

Top Contributors

[![Gomes81](https://avatars.githubusercontent.com/u/1794381?v=4)](https://github.com/Gomes81 "Gomes81 (11 commits)")

---

Tags

Guzzleauthcookie

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gomes81-guzzlehttp-cookie-auth-subscriber/health.svg)

```
[![Health](https://phpackages.com/badges/gomes81-guzzlehttp-cookie-auth-subscriber/health.svg)](https://phpackages.com/packages/gomes81-guzzlehttp-cookie-auth-subscriber)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k34](/packages/neuron-core-neuron-ai)[guzzlehttp/oauth-subscriber

Guzzle OAuth 1.0 subscriber

24215.4M149](/packages/guzzlehttp-oauth-subscriber)[eightpoints/guzzle-bundle

Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony. Comes with easy and powerful configuration options and optional plugins.

44512.5M57](/packages/eightpoints-guzzle-bundle)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

926.8M54](/packages/graham-campbell-guzzle-factory)[bilfeldt/laravel-http-client-logger

A logger for the Laravel HTTP Client

1531.8M3](/packages/bilfeldt-laravel-http-client-logger)

PHPackages © 2026

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