cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22526] - FOM cocoon.request.getCookies()'s cookies can't be read
Date Tue, 30 Nov 2004 13:33:08 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=22526>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=22526





------- Additional Comments From g.brand@interface-business.de  2004-11-30 14:33 -------
It does work with the 2.1.5.1 release here.

I will post the cookie code I am using. Note the absolute cookie path I am 
using, I think I had some trouble and this solved it but that was long ago and 
I was simply too lazy to investigate and fix it. It's a quick hack and should 
be avoided. Maybe this will give some pointers.

Gunnar.
 

/**
 * Returns true if a cookie with the given name exists.
 */
function hasCookie(name)
{
	for ( var i=new Iterator(cocoon.request.getCookies()); i.hasNext(); )
		if ( i.next().name==name ) return true;
	return false;
}


/**
 * Returns the value of a cookie.
 * If not cookie exists with the given name and a default value is given, that 
value is returned.
 * Otherwise <code>null</code> will be returned to the caller.
 */
function getCookie(name, defaultval)
{
	for ( var i=new Iterator(cocoon.request.getCookies()); i.hasNext(); ) {
		var cookie = i.next();
		if ( cookie.name==name ) return cookie.value;
	}
	return defaultval!=undefined ? defaultval : null;
}


/**
 * Adds a cookie to the response.
 * The cookie does live for a month unless a different age is given (in days).
 */
function setCookie(name, value, age)
{
	if ( cocoon==null || cocoon.response==null ) return;
	if ( value.length()>4000 ) value = value.substring(0, 4000);
	var cookie = cocoon.response.createCookie(name, value);
	cookie.maxAge = 24*3600*(age!=undefined ? age : 31);
	// this needs to be changed to the servlet context and application path 
(cocoon.request.getServletPath())!
	cookie.path = "/";
	cocoon.response.addCookie(cookie);
}


/**
 * Deletes a cookie.
 */
function deleteCookie(name)
{
	setCookie(name, "x", 0);
}


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Mime
View raw message