<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cookie_from_string(cookie_string, strict_cookies=False):
 """Parser for HTTP header set-cookie The return from this function will be used as parameters for django's response.set_cookie method. Because set_cookie doesn't have parameter comment, this cookie attribute will be ignored. :param cookie_string: A string representing a valid cookie :param strict_cookies: Whether to only accept RFC-compliant cookies :returns: A dictionary containing the cookie_string attributes """


    if strict_cookies:

        cookies = SimpleCookie(COOKIE_PREFIX + cookie_string)
        if not cookies.keys():
            return None
        cookie_name, = cookies.keys()
        cookie_dict = {k: v for k, v in cookies[cookie_name].items()
                       if v and k != 'comment'}
        cookie_dict['key'] = cookie_name
        cookie_dict['value'] = cookies[cookie_name].value
        return cookie_dict

    else:
        valid_attrs = ('path', 'domain', 'comment', 'expires',
                       'max_age', 'httponly', 'secure')

        cookie_dict = {}

        cookie_parts = cookie_string.split(';')
        try:
            key, value = cookie_parts[0].split('=', 1)
            cookie_dict['key'], cookie_dict['value'] = key, unquote(value)
        except ValueError:
            logger.warning('Invalid cookie: `%s`', cookie_string)
            return None

        if cookie_dict['value'].startswith('='):
            logger.warning('Invalid cookie: `%s`', cookie_string)
            return None

        for part in cookie_parts[1:]:
            if '=' in part:
                attr, value = part.split('=', 1)
                value = value.strip()
            else:
                attr = part
                value = ''

            attr = attr.strip().lower()
            if not attr:
                continue

            if attr in valid_attrs:
                if attr in ('httponly', 'secure'):
                    cookie_dict[attr] = True
                elif attr in 'comment':
                    # ignoring comment attr as explained in the
                    # function docstring
                    continue
                else:
                    cookie_dict[attr] = unquote(value)
            else:
                logger.warning('Unknown cookie attribute %s', attr)

        return cookie_dict