I'm trying to send a token through an Android application in the 'X-auth-token' field of the header. This request is sent to a PHP server, in which I use CodeIgniter.
Android
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(URL_PATH);
httpPost.setHeader("X-auth-token", token);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("nome", this.nome_value));
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(nameValuePairs);
httpPost.setEntity(urlEncodedFormEntity);
try {
HttpResponse httpResponse = httpClient.execute(httpPost);
//...
}
Server
...
$res = $CI->input->request_headers()['X-auth-token'];
...
Problem: $ res is not set, as if the 'X-auth-token' field did not exist.
1 - How can I send the 'X-auth-token' header field on Android?
2 - I am using the 'X-auth-token' field because I have read that it is more secure than a normal post field, to send confidential data.