Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpClient Post session issue? How do I know if session has been created?
    primarykey
    data
    text
    <p>This is a follow up question of <a href="https://stackoverflow.com/questions/3550593/sending-html-commands-over-httpclient-android">Sending html commands over httpclient android</a> , I have successfully POSTed to the server and recieved 200 code but when I attempt to move to another page it does not recognize that I have logged in. I am wondering if it is a session issue or if i need to follow the redirect after the POST. How would I go about following a redirect? Again any help is greatly appreciated. Here is a simple HttpClient / POST app I created from examples in order to help me quickly test any changes.</p> <pre><code>public class HttpClientTest extends Activity{ HttpClient client = new DefaultHttpClient(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Button btnFetch = (Button)findViewById(R.id.button); final TextView txtResult = (TextView)findViewById(R.id.content); final Button login = (Button)findViewById(R.id.button2); btnFetch.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v){ getRequest(txtResult); } }); login.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v){ try { login(txtResult); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } public void getRequest(TextView txtResult){ HttpGet request = new HttpGet("http://gc.gamestotal.com/i.cfm?f=com_empire&amp;cm=3"); try{ HttpResponse response = client.execute(request); txtResult.setText(Parser.request(response)); }catch(Exception ex){ txtResult.setText("Failed!"); } } public void login(TextView txtResult) throws UnsupportedEncodingException, IOException{ String action = "i.cfm?&amp;1028&amp;p=login&amp;se=4"; String yourServer = "http://gc.gamestotal.com/"; HttpPost post = new HttpPost(yourServer + action); List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("nic", "user")); params.add(new BasicNameValuePair("password", "password")); params.add(new BasicNameValuePair("server", "4")); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8"); post.setEntity(entity); try{ HttpResponse response = client.execute(post); txtResult.setText(response.getEntity().toString()); }catch(Exception ex){ txtResult.setText("Failed!"); } } </code></pre> <p>}</p> <p>I first press the login button on the UI which gives me the Http/1.1 200 OK response code, but when I press the btnFetch button which sends me to a page in which you must but logged in to access, I get the not logged in page. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload