Skip to content

Commit

Permalink
Merge pull request #107 from kotfire/keep-cookies-between-redirects
Browse files Browse the repository at this point in the history
[6.0] Keep cookies between redirects
  • Loading branch information
taylorotwell authored Oct 14, 2019
2 parents 8df07e5 + ae31e59 commit 4ad1c52
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Concerns/InteractsWithPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use PHPUnit\Framework\ExpectationFailedException as PHPUnitException;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\DomCrawler\Form;
use Symfony\Component\HttpFoundation\Cookie;

trait InteractsWithPages
{
Expand Down Expand Up @@ -147,7 +148,14 @@ protected function extractParametersFromForm(Form $form)
protected function followRedirects()
{
while ($this->response->isRedirect()) {
$this->makeRequest('GET', $this->response->getTargetUrl());
$this->makeRequest(
'GET',
$this->response->getTargetUrl(),
[],
collect($this->response->headers->getCookies())->mapWithKeys(function (Cookie $cookie) {
return [$cookie->getName() => $cookie->getValue()];
})->all()
);
}

return $this;
Expand Down

0 comments on commit 4ad1c52

Please sign in to comment.