private String readCookie( HttpConnection conn ) throws IOException {
String key;
String value;
String[] substrs;
for( int i = 0; ( key = conn.getHeaderFieldKey( i ) ) != null; ++i ) {
key = key.toLowerCase();
if( key.equals( "set-cookie" ) ){
value = conn.getHeaderField( i );
while( value != null ) {
substrs = Utils.split( value, ';' );
if( substrs[0].startsWith("JSESSIONID=") || // Java
substrs[0].startsWith("PHPSESSID") || // PHP
substrs[0].startsWith("SessionId") // ASP
){
return substrs[0];
}
value = substrs[1];
}
}
}
return null;
}