Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7177033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:37:42+00:00 2026-05-28T16:37:42+00:00

I am trying to make a login application so you can view grades/email teachers/etc.

  • 0

I am trying to make a login application so you can view grades/email teachers/etc.
and I can do all that but I CAN NOT get the login to work for the life of me.
Every time I try I get:

Could not retrieve user_id from the session. User timed out.
Blockquote

I have no idea what’s wrong with my code and why I can’t login.
Someone please help me. Thank you.

Code of the main “Login”:

public class GradePortalActivity extends Activity {
    private final static String SITE = "http://dcps.mygradeportal.com/";
    private TextView usernameField, passwordField;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MySoup.setSite(SITE);
        usernameField = (TextView) this.findViewById(R.id.usernameField);
        passwordField = (TextView) this.findViewById(R.id.passwordField);
    }

    public void login(View v) {
        if (usernameField.length() > 0 && passwordField.length() > 0)
            new Login().execute(new String[] { usernameField.getText().toString().trim(), passwordField.getText().toString() });
        else {
            Toast.makeText(this, "Fill out login form", Toast.LENGTH_LONG).show();
        }
    }

    private class Login extends AsyncTask<String, Void, Boolean> {
        private ProgressDialog dialog;

        @Override
        protected void onPreExecute() {
            lockScreenRotation();
            dialog = new ProgressDialog(GradePortalActivity.this);
            dialog.setIndeterminate(true);
            dialog.setMessage("Logging in...");
            dialog.show();
        }

        @Override
        protected Boolean doInBackground(String... params) {
            String username = params[0];
            String password = params[1];
            try {
                MySoup.login(username, password);
                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }

        @Override
        protected void onPostExecute(Boolean status) {
            dialog.dismiss();
            if (status == true) {
                Toast.makeText(GradePortalActivity.this, "Logged in", Toast.LENGTH_LONG).show();
                new Test().execute();
            }
            if (status == false) {
                Toast.makeText(GradePortalActivity.this, "Log in failed", Toast.LENGTH_LONG).show();
            }
        }
    }

    private class Test extends AsyncTask<String, Void, String> {
        private ProgressDialog dialog;

        @Override
        protected String doInBackground(String... params) {
            String s = MySoup.inputStreamToString(MySoup.scrape("http://dcps.mygradeportal.com/homepage.aspx"));
            return s;
        }

        @Override
        protected void onPostExecute(String s) {
            Toast.makeText(GradePortalActivity.this, s, Toast.LENGTH_LONG).show();
        }
    }

    private void lockScreenRotation() {
        switch (this.getResources().getConfiguration().orientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        }
    }

    private void unlockScreenRotation() {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }   
}

Code of “MYSOUP” (backbone of the application):

public class MySoup {

    /** The http client. */
    private static DefaultHttpClient httpClient = getHttpClient();

    /** The cookies. */
    private static List<Cookie> cookies;

    /** The http params. */
    private static HttpParams httpParams = httpClient.getParams();

    /** The username. */
    private static String username;

    /** The SITE. */
    private static String SITE;

    /** The httpget. */
    private static HttpGet httpget;

    /** The response. */
    private static HttpResponse response;

    /** The entity. */
    private static HttpEntity entity;

    /** The httpost. */
    private static HttpPost httpost;

    public static void setSite(String s) {
        if (!s.endsWith("/")) {
            s = s + "/";
        }
        if (!s.startsWith("http://") || s.startsWith("https://")) {
            s = "http://" + s;
        }
        SITE = s;
    }

    /**
     * Gets the site.
     * 
     * @return the site
     */
    public static String getSite() {
        return SITE;

    }

    /**
     * Gets the http client.
     * 
     * @return the http client
     */
    private static DefaultHttpClient getHttpClient() {
        DefaultHttpClient client = new DefaultHttpClient();
        ClientConnectionManager mgr = client.getConnectionManager();
        HttpParams params = client.getParams();



        client = new DefaultHttpClient(new ThreadSafeClientConnManager(params, mgr.getSchemeRegistry()), params);
        return client;
    }

    /**
     * Gets the session id.
     * 
     * @return the session id
     */
    public static String getSessionId() {
        return cookies.get(0).getValue();
    }

    /**
     * Gets the cookies.
     * 
     * @return the cookies
     */
    public static List<Cookie> getCookies() {
        return cookies;
    }

    /**
     * Checks if is logged in.
     * 
     * @return true, if is logged in
     */
    public static boolean isLoggedIn() {
        if ((cookies != null) && !cookies.isEmpty())
            return true;
        else
            return false;
    }

    /**
     * Login.
     * 
     * @param url
     *            the url
     * @param username
     *            the username
     * @param password
     *            the password
     * @throws CouldNotLoadException
     *             the could not load exception
     */
    public static void login(String username, String password) throws Exception {
        String url = SITE;

        try {
            httpget = new HttpGet(url);
            response = httpClient.execute(httpget);
            entity = response.getEntity();

            httpost = new HttpPost(url);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("userName", username));
            nvps.add(new BasicNameValuePair("password", password));

            httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

            response = httpClient.execute(httpost);
            entity = response.getEntity();
            if (entity != null) {
            entity.consumeContent();
            cookies = httpClient.getCookieStore().getCookies();
            }} catch (Exception e) {
            e.printStackTrace();
            throw new Exception("Could not login");
            }

            }



    /**
     * Scrape.
     * 
     * @param url
     *            the url
     * @return the input stream
     */
    public static InputStream scrape(String url) {
        httpget = new HttpGet(url);
        response = null;
        try {
            response = httpClient.execute(httpget);
            entity = response.getEntity();
            InputStream s = entity.getContent();
            System.err.println("encoding " + entity.getContentEncoding());
            return s;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }

    /**
     * Input stream to string.
     * 
     * @param is
     *            the is
     * @return the string
     */
    public static String inputStreamToString(InputStream is) {
        String line = "";
        StringBuilder total = new StringBuilder();

        BufferedReader rd = new BufferedReader(new InputStreamReader(is));
        // Read response until the end
        try {
            while ((line = rd.readLine()) != null) {
                total.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return total.toString();
    }

    /**
     * Press link.
     * 
     * @param url
     *            the url
     */
    public static void pressLink(String url) {
        url = SITE + url;
        httpget = new HttpGet(url);
        response = null;
        try {
            response = httpClient.execute(httpget);
            response.getEntity().consumeContent();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Gets the username.
     * 
     * @return the username
     */
    public static String getUsername() {
        return username;
    }

    /**
     * Sets the session id.
     * 
     * @param sessionId
     *            the new session id
     */
    public static void setSessionId(String sessionId) {
        Cookie cookie = new BasicClientCookie("", sessionId);
        CookieStore cs = new BasicCookieStore();
        cs.addCookie(cookie);
        httpClient.setCookieStore(cs);
        cookies = httpClient.getCookieStore().getCookies();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:37:44+00:00Added an answer on May 28, 2026 at 4:37 pm

    The “error”:

    Could not retrieve user_id from the session. User timed out.
    

    Is being generated from this line:

    String s = MySoup.inputStreamToString(MySoup.scrape("http://dcps.mygradeportal.com/homepage.aspx"));
    

    If you browse to http://dcps.mygradeportal.com/homepage.aspx, you’ll see that your server is generating the following error:

    Server Error in ‘/’ Application.

    Could not retrieve user_id from the session. User timed out

    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: OnCourse.Core.SWSException: Could not retrieve
    user_id from the session. User timed out

    etc…

    So what I suspect is happening is that you’re supposed to pass in a few POST parameters when scraping http://dcps.mygradeportal.com/homepage.aspx, which you’re not doing. One of those parameters is probably the elusive user_id.

    Keep in mind I can’t tell you this for sure because I don’t know how the gradeportal service works, but this should help you troubleshoot your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an application that can connecto to facebook. I've found Facebook
I am trying to make an application using AppleScript which can remind to check
I'm trying to make an OAuth 2.0 Provider and an Android application that is
I am trying to make a login script for my android application, the script
Now I'm trying to work with System.Web.Routing. All is just fine, but I can't
Alright so here is the deal. I am trying to make a application that's
I'm trying to make a Facebook video application so users can have a video
I'm trying to connect to facebook from my iOS application, so I can make
I'm trying to automate the Google Docs login process, but the methods that I
I'm trying make a login window where a user is prompted to enter their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.