[opencms-dev] Cookies in OpenCMS again ...

Urich, Chase ChaseUrich at letu.edu
Tue May 13 22:42:01 CEST 2003


I've proven that my cookie code works by running it in a different
webapp. Is there a reason that it doesn't work in OpenCMS? I have the
path set to "/" ... Is there something OpenCMS specific that I'm
missing? My code has been included below for reference:

<!-- cookie.jsp (page 1) -->
<%@ page import="javax.servlet.http.*" %>
<%
	Cookie cookie = new Cookie ("cookieName", "cookieValue");
	cookie.setPath("/");
	cookie.setMaxAge(365 * 24 * 60 * 60);
	response.addCookie(cookie);
%>
<html><head></head><body>
Cookie Set? ... hopefully.<br />
<a href='cookie2.jsp'>Cookie 2 test</a>
</body>
</html>

<!-- cookie2.jsp (page 2) -->
<%@ page import="java.net.*"%>
<HTML>
<HEAD>
</HEAD>
<BODY><pre><%
	String cookieName = "Username";
	Cookie cookies[] = request.getCookies ();
	for (int i = 0; i < cookies.length; i++) {
		out.println(cookies[i].getName() + " -> " +
cookies[i].getValue());
	}
%></pre>
<a href='cookie.jsp'>Cookie test</a>
</BODY>
</HTML>

Chase Urich
Web Programmer
LeTourneau University



More information about the opencms-dev mailing list