Maintaining session in android ( application stay authenticated on the server side) -


i building login application in android in hitting url(with username , password) upto part works fine after whenever hitting url(once user authenticated) , return nothing(i.e. error message please login first). works fine in similar iphone app , on browser.

i got somewhere error of phpsessionid(i.e. session destroyed further request) , if want our android application stay authenticated on server side need fetch id after first connection , send in headers of our subsequent requests.

but problem unable sessionid header of first connection , sending further request along header.

please give me codes or links complete task properly. thanks.

finally solved issue of session handling in android. android cant handle session itself(which simple browser can) have handle explicitly. changed code http connection bit. created instance of defaulthttpclient in first activity when connection established.

public static defaulthttpclient httpclient; 

for first time connection,i did following:

url url=new url(urltohit); loginscreen.httpclient = new defaulthttpclient(); //loginscreen name of current activity  httppost httppost = new httppost(url.tostring()); httpresponse response = loginscreen.httpclient.execute(httppost);   xr.parse(new inputsource(url.openstream())); //sax parsing 

now further connections used same httpclient example in next activity:

url url=new url(urltohit);  httppost httppost = new httppost(url.tostring()); httpresponse response = loginscreen.httpclient.execute(httppost);   // log.v("response code",""+response.getstatusline().getstatuscode());  // hold of response entity httpentity entity = response.getentity();  inputstream instream = null;  if (entity != null) {     instream = entity.getcontent(); } xr.parse(new inputsource(instream)); //sax parsing 

hope solve session issue in android.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -