简体   繁体   中英

How to get session id from cookie?

I take away all the cookies, and what I get is: JSESSION=234234fsdf23 .
But I only need a value without JSESSION .
Please tell me how to do this?

  Headers header = response.headers();
  List<String> cookieList = header.values("Set-Cookie");
  String jsessionid = (cookieList.get(0).split(";"))[0];

I got it this way:

String header = response.headers().get("Set-Cookie");
       String arr[] = header.split("=");
       String jsessionid = arr[1];
       jsessionid = jsessionid.substring(0,jsessionid.length()-5);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM