2 Replies Latest reply on Jun 1, 2010 8:21 AM by engheba

    Cookie in seam

    engheba

      i am working on seam project . i need to add cookie to use it through the application .
      I asking if seam enable general use of  cookie and if true how can i add cookie????????

        • 1. Re: Cookie in seam
          babazs
          Try these lines for add an entry to the cookie:

               Cookie cookie = new Cookie("name",id);
               cookie.setMaxAge(maxAge);
               cookie.setPath("/xyzPath");
               ((HttpServletResponse) facesContext.getExternalContext().getResponse()).addCookie(cookie);

          And these lines for retrieve an entry from the cookie:

          for (Cookie cookie : ((HttpServletRequest) facesContext. getExternalContext() .getRequest()).getCookies()) {
          if(cookie.getName().equals("name")){...}
          }
          • 2. Re: Cookie in seam
            engheba

            Balázs Bakai thanks for your replay.
            i tried  this code but the length of the cookies array is 1
            and this cookie is jsessionid
            Unfortunately there is no cookie added.