public function RedirectResponseWithCookie::__construct in LDAP Single Sign On 8
Same name and namespace in other branches
- 8.4 src/RedirectResponseWithCookie.php \Drupal\ldap_sso\RedirectResponseWithCookie::__construct()
Creates a valid redirect response and pushes cookies with them.
Parameters
string $url: The URL to redirect to.
int $status: The status code (302 by default)
array $cookies: An array of Cookie objects.
File
- src/
RedirectResponseWithCookie.php, line 29
Class
- RedirectResponseWithCookie
- An HTTP response doing a redirect and sending cookies.
Namespace
Drupal\ldap_ssoCode
public function __construct($url, $status = 302, array $cookies = []) {
parent::__construct($url, $status);
foreach ($cookies as $cookie) {
if (!$cookie instanceof Cookie) {
throw new \InvalidArgumentException(sprintf('One of third parameter array is not a valid Cookie object.'));
}
$this->headers
->setCookie($cookie);
}
}