docs: def get_cookies_for_class(session, class_name,
                            cookies_file=None,
                            username=None,
                            password=None):
      """
      Get the cookies for the given class.
  
      We do not validate the cookies if they are loaded from a cookies file
      because this is intended for debugging purposes or if the coursera
      authentication process has changed.
      """
      if cookies_file:
          cookies = find_cookies_for_class(cookies_file, class_name)
          session.cookies.update(cookies)
          logging.info('Loaded cookies from %s', cookies_file)
      else:
          cookies = get_cookies_from_cache(username)
          session.cookies.update(cookies)
          if validate_cookies(session, class_name):
              logging.info('Already authenticated.')
          else:
              get_authentication_cookies(session, class_name, username, password)
              write_cookies_to_cache(session.cookies, username)