public static Cookie getCookie ( HttpServletRequest req , String name ) { Cookie [ ] cookies = req . getCookies ( ) ; if ( cookies != null ) { for ( int ii = 0 , nn = cookies . length ; ii < nn ; ii ++ ) { if ( cookies [ ii ] . getName ( ) . equals ( name ) ) { return cookies [ ii ] ; } } } return null ; // not found }
Get the cookie of the specified name or null if not found .