Understanding Cookies

There might be times when you don't need the advanced features of client-state management, but you still have some user-specific data you'd like to preserve, for example, a quick check to see if a user has "logged in." Or, you might find yourself in a situation wherein a Web hosting service doesn't support client-state.

In either case, ColdFusion enables you to use cookies independently of its client-state management feature. It does this with a tag called <CFCOOKIE>, and using it is very similar to the methods described in the previous sections.

Setting Cookies

To set a cookie, you specify a name, a value and an expiration date within the tag:

<CFCOOKIE NAME="some_variable"
          VALUE="some_value"
          EXPIRES="7">

The cookie will ...

Get Sams Teach Yourself ColdFusion® in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.