J2ME Read Cookies

- 中国WEB开发者网络 (http://www.webasp.net)
-- 技术教程 (http://www.webasp.net/article/)
--- J2ME Read Cookies (http://www.webasp.net/article/15/14294.htm)
-- 作者:未知
-- 发布日期: 2004-10-27
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;
}



webasp.net