guzzle/guzzle — pull request #33 by cboden (2012-03-06 16:27:17+00:00)
Title: Serializable Cookies

By adding the Serializable interface to ArrayCookieJar it allows users to use any storage medium to save their cookies to.

An alteration of the website example (using PDO, but can be swapped with anything [Memcache, Redis, file, etc]):

```php
getEventDispatcher()->addSubscriber($plugin);
$request = $client->get('http://www.yahoo.com/');

// Send the request with no cookies and parse the returned cookies
$request->send();

// Send the request again, noticing that cookies are being sent
$request->send();

// Save your cookies!
$flatCookie = serialize($jar);
$dbh = new \PDO('mysql:dbname=testdb;host=localhost', 'user', 'pass');
$dbh->prepare("INSERT INTO `cookies` VALUES (?)")->execute(array($flatCookie));

echo $request;
```
***

The following page load or CLI script:

```php
query("SELECT `flatCookie` FROM `cookies`")->fetchAll(\PDO::FETCH_ASSOC);
$flatCookie = $data[0]['flatCookie'];

$jar = unserialize($flatCookie);
// etc, etc
```