J2ME Read Cookies

作者:袖梨 2022-07-02
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;
}

相关文章

精彩推荐