def cookies_str_to_dict(cookies):
    """
    Convert cookies from str to dict.
    """
    if not isinstance(cookies, str):
        raise TypeError('Invalid type of cookies_string !')
    cookies_obj = {}
    for item in cookies.split(';'):
        item = item.strip().replace('\t', '').replace('\n', '')
        if '=' not in item:
            continue
        key, value = item.split('=', 1)
        cookies_obj[key] = value
    return cookies_obj
