public boolean doLogin() {
        
        Transport transport = plugin.getTransport();

        HashMap<String, String> map = new EasyHashMap<String, String>(
                "user", username,
                "passwd", password,
                "api_type", "json");

        Request request = new WebRequest(plugin, map);
        request.setURL(plugin.getRedditURL() + "/api/login");
        request.setMethod(RequestType.POST);
        transport.setRequest(request);

        Response response = transport.sendURL();
        password = "";
        
        JSONResult json = response.getJSONResult();
        
        if (!json.getStringList("json/errors").isEmpty()) {
            throw new APIException(json.getStringList("json/errors").get(0));
        }
        
        for( Cookie cookie : response.getCookies() ) {
            if( cookie.getName().equals("reddit_session") ) {                
                plugin.setCookie(cookie);
            }
        }
        
        if( plugin.getCookie() == null ) {
            throw new NetworkException("No cookie was found. Check the username and password.");
        }
        
        plugin.setModHash(json.getString("json/data/modhash"));
        
        return true;
    }