>      if (cookies[i].getName().equals("memberCookie")); {
It looks like the problem is the semicolon after the "if()"  ^
This code will print out all the cookies, not just the "memberCookie".

----- Original Message -----
From: "Paul Wallace" <[EMAIL PROTECTED]>
To: "Tomcat Developers List" <[EMAIL PROTECTED]>
Sent: Monday, March 11, 2002 12:58 PM
Subject: cookie retrieval II


> Hello Everyone,
>     Similar to a previous posting, I have some code to make a cookie:
>
> Cookie cook = new Cookie("memberCookie", userid);
> cook.setPath("/mydir");
> response.addCookie(cook);
>
> and to retreive the cookie:
>
> Cookie cookies[] = request.getCookies();
> for(int i = 0; i < cookies.length; i++) {
>      if (cookies[i].getName().equals("memberCookie")); {
>     out.println("Welcome: " + cookies[i].getValue() + "<p>");
>     }
>  }
>
> to retrieve the cookie. It retrieves the value but with an additional
> nuisance. I get the desired cookie, but also what appears to be the
session
> ID (output below).
>
> Welcome: paul
> Welcome: 61D0D4C3E11302B07308C3D960D13840
>
> I am obviously looping through the length of the cookies array, retrieving
> the value, but also this unwanted text. What can I do to retrieve just the
> value please? It looks like my if condition is being satisified twice?!
>
> Frustrated
>
> Paul.
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to