You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Kevin Sonney <ke...@webslingerz.com> on 2000/07/28 16:10:13 UTC

Cookies revisited

So I'm still mucking with the cookie xsp logic sheet. I've got something
that works, but it required some thinking, and a small change or two to
the cookie logic sheet. I'll post that diff in a seperate message.

As far as I can tell, the proper way to set a cookie is the following :

<!-- Begin XML Snippet -->
<xsp:logic>
Cookie cookie = <cookie:create name="test">
	<value>Kevin</value>
	<cookie:set-comment>
		<purpose>Kevin's Cookie Cookie</purpose>
	</cookie:set-comment>
</cookie:create> ;
<cookie:set-max-age>
	<expiry>172800</expiry>
</cookie:set-max-age>
<cookie:set-domain> 
	<pattern>.webslingerz.com</pattern>
</cookie:set-domain>
<cookie:set-path path="/~kevin/" />
<cookie:set-version value="1" />
<response:add-cookie><xsp:logic>cookie</xsp:logic></response:add-cookie>
</xsp:logic>
<!-- End XMl Snippet -->

This actually sets a cookie named "test" for the .webslingerz.com domain
path /~kevin/ for 24 hours with the data "Kevin". The generated source
looks like : 

// Begin generated Java code
Cookie cookie = 
      new Cookie(
        String.valueOf("test"),
        String.valueOf("Kevin")
      )
    

	 ;

      cookie.setMaxAge(
        Integer.parseInt(
          String.valueOf(
            "172800"
          )
        )
      );
    
      cookie.setPath(
        String.valueOf(
          "/~kevin/"
        )
      );

      cookie.setDomain(
	String.valueOf(
	  ".webslingerz.com"
	)
      );
    
      cookie.setVersion(
        Integer.parseInt(
          String.valueOf(
            "1"
          )
        )
      );
    
      response.addCookie(
        cookie
        
      );
 // end generated java code

My thinking is there's got to be a bteer way to do this, but I haven't the
gumption to re-write the logic sheet at the moment. 

-- 
+-------------------------------------------+
| Kevin Sonney        kevin@webslingerZ.com |
| Systems Programmer    www.webslingerZ.com |
+-------------------------------------------+