public static String getCookieValue ( ServletRequest request , String key ) { Cookie [ ] cookies = ( ( HttpServletRequest ) request ) . getCookies ( ) ; if ( cookies != null ) { for ( int i = 0 ; i < cookies . length ; i ++ ) { if ( cookies [ i ] . getName ( ) . equals ( key ) ) { return cookies [ i ] . getValue ( ) ; } } } return null ; }
Retrieves a value from a cookie