[opencms-dev] setting cookies in OpenCms doesn't work.

Millo Magnocavallo millo_magno at yahoo.com
Fri Sep 17 22:50:00 CEST 2004


I seem to get the same problem when trying to get the value back. I've
tried the respective code to get it out but it doesn't work:

	String autoLoginValue = "";
	Cookie[] cookies =
((HttpServletRequest)cmsObj.getRequestContext().getRequest().getOriginalRequest()).getCookies();
	if (cookies != null) {
		out.print( cookies.length);
		for (int i=0; i < cookies.length; i++) {
			out.print(cookies[i].getName());
		}
	}

The cookies.length returns 1 when it should be 2 and the 2 names that
should correspond with each is 1 for JSESSIONID and 1 for autoLogin.
The autoLogin name or value don't appear ?????

Is this another bug? and is there a workaround here?

M


 --- Stephan Hartmann <beffe at beffe.de> wrote: 
> If you are talking about OpenCms version 5.0 or 5.0.1, this is a bug.
> Here is  a workaround (cmso is a CmsObject):
> 
>
((HttpServletResponse)cmso.getRequestContext().getResponse().getOriginalResp
> onse()).addCookie(cookie);
> 
> Bye,
> Stephan
> ----- Original Message -----
> From: "Millo Magnocavallo" <millo_magno at yahoo.com>
> To: <opencms-dev at opencms.org>
> Sent: Friday, September 17, 2004 6:56 PM
> Subject: [opencms-dev] setting cookies in OpenCms doesn't work.
> 
> 
> > Hi,
> >
> > Can anyone tell me why I can't set cookies in OpenCms? Do I need to
> > have something turned on, is there a special configuration change I
> > have to make? This is the following code which i've tested and
> works
> > fine in a tomcat jsp environment yet doesn't work in OpenCms:
> >
> > <html>
> > <body>
> > <head><title>setting cookies</title></head>
> > <%
> > Cookie cookie = new Cookie("autoLogin","true");
> > cookie.setMaxAge(2147483647);
> > response.addCookie(cookie);
> >
> > Cookie[] cookies = request.getCookies();
> > out.print("<br>cookies.length = " + cookies.length + "<br>");
> > if (cookies != null) {
> > for (int i=0; i < cookies.length; i++) {
> > out.print("<br>cookie" + i + " name:" + cookies[i].getName());
> > out.print("<br>cookie" + i + " value:" + cookies[i].getValue());
> > }
> > }
> > %>
> > </body>
> > </html>
> >
> > Your help appreciated,
> > M
> >
> >
> > _______________________________________________
> > This mail is send to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list,
> please visit
> > http://mail.opencms.org/mailman/listinfo/opencms-dev
> >
> 
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
> visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>  



More information about the opencms-dev mailing list