src/Http/Cookie/Cookie.php
public static function fromString($value)
    {
        $parts = array_filter(array_map('trim', explode(';', $value)));

        if (empty($parts) || !strpos($parts[0], '=')) {
            return [];
        }
        $config = [];

        $pieces = explode('=', array_shift($parts), 2);

        if (count($pieces) !== 2) {
            return [];
        }
        $config['name'] = trim($pieces[0]);
        $config['value'] = urldecode(trim($pieces[1], " \n\r\t\0\x0B"));

        foreach ($parts as $item) {
            $pieces = explode('=', trim($item), 2);
            $pieces[0] = strtolower($pieces[0]);
            if (count($pieces) !== 2) {
                $config[$pieces[0]] = true;
            } else {
                $config[$pieces[0]] = $pieces[1];
            }
        }
        return new static($config);
    }
public static function fromString($value)
    {
        $parts = array_filter(array_map('trim', explode(';', $value)));

        if (empty($parts) || !strpos($parts[0], '=')) {
            return [];
        }
        $config = [];

        $pieces = explode('=', array_shift($parts), 2);

        if (count($pieces) !== 2) {
            return [];
        }
        $config['name'] = trim($pieces[0]);
        $config['value'] = urldecode(trim($pieces[1], " \n\r\t\0\x0B"));

        foreach ($parts as $item) {
            $pieces = explode('=', trim($item), 2);
            $pieces[0] = strtolower($pieces[0]);
            if (count($pieces) !== 2) {
                $config[$pieces[0]] = true;
            } else {
                $config[$pieces[0]] = $pieces[1];
            }
        }
        return new static($config);
    }
public static function fromString ( $ value ) { $ parts = array_filter ( array_map ( 'trim' , explode ( ';' , $ value ) ) ) ; if ( empty ( $ parts ) || ! strpos ( $ parts [ 0 ] , '=' ) ) { return [ ] ; } $ config = [ ] ; $ pieces = explode ( '=' , array_shift ( $ parts ) , 2 ) ; if ( count ( $ pieces ) !== 2 ) { return [ ] ; } $ config [ 'name' ] = trim ( $ pieces [ 0 ] ) ; $ config [ 'value' ] = urldecode ( trim ( $ pieces [ 1 ] , " \n\r\t\0\x0B" ) ) ; foreach ( $ parts as $ item ) { $ pieces = explode ( '=' , trim ( $ item ) , 2 ) ; $ pieces [ 0 ] = strtolower ( $ pieces [ 0 ] ) ; if ( count ( $ pieces ) !== 2 ) { $ config [ $ pieces [ 0 ] ] = true ; } else { $ config [ $ pieces [ 0 ] ] = $ pieces [ 1 ] ; } } return new static ( $ config ) ; }
Create a new Cookie object from a Set-Cookie header value

@param string $value Set-Cookie header value.

@return self
Create a new Cookie object from a Set - Cookie header value