AxKit::XSP::Cookie - An XSP library for setting and getting HTTP cookies.


AxKit-XSP-Cookie documentation  | view source Contained in the AxKit-XSP-Cookie distribution.

Index


NAME

Top

AxKit::XSP::Cookie - An XSP library for setting and getting HTTP cookies.

SYNOPSIS

Top

Add the taglib to AxKit (via httpd.conf or .htaccess):

    AxAddXSPTaglib AxKit::XSP::Cookie

Add the cookie: namespace to your XSP <xsp:page> tag:

    <xsp:page
         language="Perl"
         xmlns:xsp="http://apache.org/xsp/core/v1"
         xmlns:cookie="http://axkit.org/NS/xsp/cookie/v1"
    >

Then, put the taglib to work:

Set a cookie:

    <cookie:create name="newCookie" value="somevalue" />

Get the value for a previous cookie:

    <cookie:fetch name="oldCookie" />

DESCRIPTION

Top

The XSP cookie: tag library implements a simple way to set/get HTTP cookies.

TAG REFERENCE

Top

In order to provide maximum flexibility for XSP developers, the cookie: taglib allows all of its arguments to be passed either as attributes of the two 'wrapper' elements (<cookie:create> and <cookie:fetch>), or as child elements of the same.

In practice, the choice between passing arguments as attributes vs. passing them as child elements boils down to whether or not the value being passed is being set dynamically or not. If the arguments are hard-coded, you can safely pass the values as either an attribute or a child element. If, however, you need to pass a value that is not defined until run-time, you must use a child element since XSP does not allow the value of taglib attributes to be set dynamically. See the EXAMPLES below for clarification.

EXAMPLES

Top

Fetch the value for a previous cookie whose name argument is hard-coded into the script:

    <cookie:fetch name="chocolateChip"/>

Fetch the value for a previous cookie whose name is determined at run-time:

    <cookie:fetch>
      <cookie:name><xsp:expr>$perl_var_containing_cookiename</xsp:expr></cookie:name>
    </cookie:fetch>

Set a cookie using only hard-coded arguments:

    <cookie:create
            name="oatmealRaisin"
            value="tasty"
            expires="+3M"
    >

Set a cookie using a mix of dynamic child elements and static attributes:

    <cookie:create
            name="peanutButter"
            domain=".mydomain.tld"
            secure="1"
    >
      <cookie:value><xsp:expr>$cookie_value</xsp:expr></cookie:value>
      <cookie:expires><xsp:expr>$cookie_expiry</xsp:expr></cookie:expires>
      <cookie:path><xsp:expr>$cookie_path</xsp:expr></cookie:path>
    </cookie:create>

As stated above, you can pass static arguments either as attributes or child elements of the enclosing tag. Thus:

    <cookie:create name="pistachioChocolateChunk"/>
      ...

and

    <cookie:create>
      <cookie:name>pistachioChocolateChunk</cookie:name>
      ...

are functionally equivalent.

AUTHOR

Top

Kip Hampton, khampton@totalcinema.com

COPYRIGHT

Top

SEE ALSO

Top

AxKit, Apache::Cookie, CGI::Cookie


AxKit-XSP-Cookie documentation  | view source Contained in the AxKit-XSP-Cookie distribution.