/**
* Gets a cookie by name.
*
* You should never use an empty domain, but if you do so,
* this method returns the first cookie for the given name/path
* (this behavior ensures a BC behavior with previous versions of
* Symfony).
*/
public function get(string
$name, string
$path = '/', string
$domain = null
): ?Cookie
{ $this->
flushExpiredCookies();
foreach ($this->cookieJar
as $cookieDomain =>
$pathCookies) { if ($cookieDomain &&
$domain) { $cookieDomain = '.'.
ltrim($cookieDomain, '.'
);
if (!
str_ends_with('.'.
$domain,
$cookieDomain)) { continue;
} } foreach ($pathCookies as $cookiePath =>
$namedCookies) { if (!
str_starts_with($path,
$cookiePath)) {