Free-Conversant Support / Using Cookies
 Home   About Conversant   Free Sites   Hosting   Support   XML-RPC 

Search




Subject Using Cookies
Posted 9/6/2002; 11:47 AM by Greg Pierce
Last Modified 8/9/2003; 12:52 PM by Seth Dillingham
In Response To (#Top of Thread.)
Label Docs Read 6223
<Previous Next>

Using Cookies

Conversant provides a set of macros for setting and displaying values of persistent HTTP cookies, and also conditional macros that allow you to customize the output of the rendering process based on the contents of a cookie. For more information on cookies, see the Cookie Specification.

Two macros are supplied, #setCookie allows you to set a cookie to be sent back to the client's browser along with the current request, and #cookie allows you display the current value of a cookie that was returned to the server along with a client request. Also, Conditional macros are provided to test the values of cookies and control content based on their values.

Cookies can be used for a broad range of uses. We have provided an example page documenting one way to customize the user experience with cookie macros.

There is no explicit way to delete a cookie previously set, it is recommended you use #setCookie to set the value of the cookie to a empty string ( "" ) to delete a cookie.

Cookie Macros

<!--#setCookie-->

Sets a cookie in the http response for the current page. For more information on cookies, see the Cookie Specification.

Required Attributes:
  • name="[cookie name]" : The name to used for the cookie.
  • value="[cookie value]" : The value to used for the cookie. For details on setting values see below.
Optional Attributes
  • type="[string/date]" : Data type for the cookie value attribute. Default: string. If the value "date" is used, Conversant will attempt to contruct a net standard date string from the string passed in value, so, for example, "1/1/2002" would become "Tue, 01 Jan 2002 05:00:00 GMT". When type is set to "date", Conversant also support the special relative values: "now", "now+[number of seconds]", and "now-[number of seconds]". "now" will be evaluated to the current time. To set a cookie that will expire in one minute, you could send the value attribute "now+60" with a type attribute set to "date".
  • expires="[string]" : Default: No expires attribute is set for the cookie, it will be a session cookie and expire when the client browser is quit.
  • path="[string]" : The path within the site for which the cookie is valid. Default: "/" or the whole domain.
  • secure="[true/false]" : If true, the client will only send the cookie over a secure HTTP transport. Default: false.
  • domain="[string]" : The domain for which the cookie is valid. This should not need to be used in standard cookie definitions. Default: The domain of the request.

<!--#cookie-->

Displays the value of a cookie present in the HTTP request for the current page. For more information on cookies, see the Cookie Specification.

Required Attributes:
  • name="[cookie name]" : The name to used for the cookie.
Optional Attributes
  • type="[string/date]" : Data type for the cookie value attribute. Default: string. If type is set to "date", the value will be assumed to be a net standard date string, and the macro will support the additional attribute of Conversant's date formatting features.

Cookie Conditional Macros

The cookie conditional macros are documented with the rest of the conditionals.

<Previous Next>
ENCLOSURES

None.
REPLIES

RE: Using Cookies
5/11/2003 by Brian Carnell
"expires="[string]" : Default: No expires attribute is set for the cookie,

How to Set and Use Cookie-based Preferences
8/9/2003 by Seth Dillingham
How to Set and Use Cookie-based Preferences in Conversant Conversant provides


TRACKBACKS