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(3y ago)119711MITPHPPHP &gt;=5.5.0CI failing

Since Jan 25Pushed 3y 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 2mo 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 43% 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

1446d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6430173907390179b32cd112bf63a130974ec79bcc9eee0297c5a8221d2c626e?d=identicon)[Gomes](/maintainers/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

[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43117.4M104](/packages/kevinrob-guzzle-cache-middleware)[eightpoints/guzzle-bundle

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

45912.1M55](/packages/eightpoints-guzzle-bundle)[guzzlehttp/oauth-subscriber

Guzzle OAuth 1.0 subscriber

24114.5M141](/packages/guzzlehttp-oauth-subscriber)[caseyamcl/guzzle_retry_middleware

Guzzle v6+ retry middleware that handles 429/503 status codes and connection timeouts

21610.7M64](/packages/caseyamcl-guzzle-retry-middleware)[php-http/guzzle7-adapter

Guzzle 7 HTTP Adapter

9057.1M555](/packages/php-http-guzzle7-adapter)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

916.4M49](/packages/graham-campbell-guzzle-factory)

PHPackages © 2026

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