code: def login_user(server, login, password):
      
      login_url = urljoin(server, login_url_prefix)
  
      # Start the web session
      session = requests.session()
      result = session.get(login_url)
  
      # Check if the request ok
      if not result.ok:
          message = (tr(
              'Request failed to {geonode_url}, got status code {status_code} '
              'and reason {request_reason}').format(
                  geonode_url=server,
                  status_code=result.status_code,
                  request_reason=result.reason))
          raise GeoNodeInstanceError(message)
  
      # Take the CSRF token
      login_form_regexp = (
          "<input type='hidden' name='csrfmiddlewaretoken' value='(.*)' />")
      expression_compiled = re.compile(login_form_regexp)
      match = expression_compiled.search(result.text)
      csrf_token = match.groups()[0]
  
      payload = {
          'username': login,
          'password': password,
          'csrfmiddlewaretoken': csrf_token,
      }
  
      # Make the login
      result = session.post(login_url, data=payload, headers=dict(
          referer=login_url))
  
      # Check the result url to check if the login success
      if result.url == login_url:
          message = tr('Failed to login to GeoNode at {geonode_url}').format(
              geonode_url=server)
          raise GeoNodeLoginError(message)
  
      return session
docs: Get the login session.
  
      :param server: The Geonode server URL.
      :type server: basestring
  
      :param login: The login to use on Geonode.
      :type login: basestring
  
      :param password: The password to use on Geonode.
      :type password: basestring