php - Android: login and getting PHPSESSID from the response from the server? -


i'm such newbie on android , knowledge between client-server.
i'm making android app in need login (like social network). made registration activity saving data mysql on db. problem comes login. can verify if username , password correct in order don't have login again untill server session closed need save phpsessid server , check everytime want see "protected" activity home of social network or profile.
if session cookie not anymore on server need login again new session cookie created.
questions are:
how can phpsessid login script?
correct save in sharedpreferences in order send check server?
here's code unitll now:

`public string sendpostrequest(string requesturl, hashmap postdataparams) {

    url url;     string response = "";     try {         url = new url(requesturl);          httpurlconnection conn = (httpurlconnection) url.openconnection();         conn.setreadtimeout(15000);         conn.setconnecttimeout(15000);         conn.setusecaches(true);         conn.setrequestmethod("post");         conn.setdoinput(true);         conn.setdooutput(true);           outputstream os = conn.getoutputstream();         bufferedwriter writer = new bufferedwriter(                 new outputstreamwriter(os, "utf-8"));         writer.write(getpostdatastring(postdataparams));          writer.flush();         writer.close();         os.close();         int responsecode = conn.getresponsecode();          if (responsecode == httpsurlconnection.http_ok) {             bufferedreader br = new bufferedreader(new inputstreamreader(conn.getinputstream()));             response = br.readline();         } else {             response = "error";         }     } catch (exception e) {         e.printstacktrace();     }      return response; }  private string getpostdatastring(hashmap<string, string> params) throws unsupportedencodingexception {     stringbuilder result = new stringbuilder();     boolean first = true;     (map.entry<string, string> entry : params.entryset()) {         if (first)             first = false;         else             result.append("&");          result.append(urlencoder.encode(entry.getkey(), "utf-8"));         result.append("=");         result.append(urlencoder.encode(entry.getvalue(), "utf-8"));     }      return result.tostring(); }` 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -