Issue
I am doing a webview project in android java in cordova framework .The session id is sent as cookie from the server when user logs in.I need the session id for maintaining the session. I am getting cookie as
ASP.NET_Session_Id=123345; yourAuthCookie=6415176A0448E891D99DAA57BBB7FC77785AD0A3F2BCBAF660957E1CE4A7C3D47E5FDF1DDA522FBC1306C96A50029E088805CC1ECC223CE0B4A29286327907779F5FFEBD8F6AA8B2CE685579667BB29D4CBC50C1EEA
I just want session id . How can i get just the session id from cookie?
Solution
After some research i found an answer,
public String cookieElement(String Url,String CookieName){
String CookieValue = null;
CookieManager cookieManager = CookieManager.getInstance();
String cookies = cookieManager.getCookie(Url);
String[] temp=cookies.split(";");
for (String ar1 : temp ){
if(ar1.contains(CookieName)){
String[] temp1=ar1.split("=");
CookieValue = temp1[1];
break;
}
}
return CookieValue;
}
the function can be called as
String sessionid = cookieElement("https://www.example.com/","ASP.NET_Session_Id");
Answered By - Daniel X
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.