Skip to content

Commit bf53b5c

Browse files
committed
Tweaks
1 parent 675ad18 commit bf53b5c

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

components/browser_kit.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,19 @@ into the client constructor::
288288
$client = new Client([], null, $cookieJar);
289289
// ...
290290

291+
.. _component-browserkit-sending-cookies:
292+
291293
Sending Cookies
292294
~~~~~~~~~~~~~~~
293295

294-
By setting the ``Cookie`` header value, you are able to send cookies with your
295-
request thanks to the ``serverParameters`` argument of the
296-
:method:`Symfony\\Component\\BrowserKit\\AbstractBrowser::request` method::
296+
Requests can include cookies. To do so, use the ``serverParameters`` argument of
297+
the :method:`Symfony\\Component\\BrowserKit\\AbstractBrowser::request` method
298+
to set the ``Cookie`` header value::
297299

298300
$client->request('GET', '/', [], [], [
299301
'HTTP_COOKIE' => new Cookie('flavor', 'chocolate', strtotime('+1 day')),
300302

301-
// you're also able to pass a string instead
303+
// you can also pass the cookie contents as a string
302304
'HTTP_COOKIE' => 'flavor=chocolate; expires=Sat, 11 Feb 2023 12:18:13 GMT; Max-Age=86400; path=/'
303305
]);
304306

http_client.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,9 @@ requires a stateful storage (because responses can update cookies and they must
682682
be used for subsequent requests). That's why this component doesn't handle
683683
cookies automatically.
684684

685-
You can either handle cookies yourself using the ``Cookie`` HTTP header or use
686-
the :doc:`BrowserKit component </components/browser_kit>` which provides this
687-
feature and integrates seamlessly with the HttpClient component.
688-
689-
However, you're able to send cookies in your request. This is how you can do
690-
so using :class:`Symfony\\Contracts\\HttpClient\\HttpClient`::
685+
You can either :ref:`send cookies with the BrowserKit component <component-browserkit-sending-cookies>`,
686+
which integrates seamlessly with the HttpClient component, or manually setting
687+
the ``Cookie`` HTTP header as follows::
691688

692689
use Symfony\Component\HttpClient\HttpClient;
693690
use Symfony\Component\HttpFoundation\Cookie;
@@ -696,7 +693,7 @@ so using :class:`Symfony\\Contracts\\HttpClient\\HttpClient`::
696693
'headers' => [
697694
'Cookie' => new Cookie('flavor', 'chocolate', strtotime('+1 day')),
698695

699-
// you're also able to pass a string instead
696+
// you can also pass the cookie contents as a string
700697
'Cookie' => 'flavor=chocolate; expires=Sat, 11 Feb 2023 12:18:13 GMT; Max-Age=86400; path=/'
701698
],
702699
]);

0 commit comments

Comments
 (0)