HOW-TO: Getting portal cookies from JSR-168 portlets

VAP actually adds the "cookie" http header(s) to the PortletRequest properties collection, according to the JSR168 spec, section PLT.11.1.4. So from within a JSR168 portlet it's quite simple to get the cookies from the RenderRequest.getProperties("cookie").

Code Example:

[...]

Cookie getCookie(String name, PortletRequest request)
{	
    String [] cookie = null;
    
    for(StringTokenizer st = new StringTokenizer("cookie", "; "); st.hasMoreTokens();)
    {
        cookie = st.nextToken().split("=");
        if(cookie.length == 2 && cookie[0].equals(name))
        {
            return new Cookie (cookie[0], cookie[1]);
        }   
}

return null;
}

[...]

source: http://weblogs.asp.net/jdanforth/archive/2005/08/18/422957.aspx