Hi Liam,
Yes you can write an action to set a cookie and have the sitemap determine
when to call the action.
I use an action that sets a cookie according to request parameters.
This code should do the trick, just fill in the blanks:
---------------------------------------------------
import java.util.Map;
import java.util.HashMap;
import java.util.Enumeration;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.Constants;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.components.language.markup.xsp.XSPCookieHelper;
public class StoreCookieAction extends AbstractAction
{
public Map act(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par)
throws Exception
{
Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
String remember_user = request.getParameter("remember");
if (remember_user != null && remember_user.equals("on"))
{
String value = ;
String name = ;
String comment = ;
String domain = ;
int maxage = ;
String path = ;
String secure = ;
int version = ;
XSPCookieHelper.addCookie(objectModel, name, value, comment,
domain,
maxage, path, secure, version);
}
return new HashMap();
}
}
------------------------------------------------
Hope this helps,
Best Regards,
Chris
-----Original Message-----
From: Liam Morley [mailto:[EMAIL PROTECTED]]
Sent: 06 December 2001 23:45
To: [EMAIL PROTECTED]
Subject: RE: Cocoon2 Cookie Recipe?
And if you're not using XSP, what then? Is it possible to set cookies
within the sitemap/XSL, using a Java Cocoon action?
Liam Morley
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>