Coldfusion SESSION and COOKIE scope

Working with both SESSION and COOKIE scope tripped me up today so I wanted to illustrate what went wrong so hopefully others can avoid this.

Example 1:


This sets a session variable that will exist for the life of the session.

Example 2:


This sets a cookie that will exist for the life of the browser session.

Example 3:


This sets a cookie that will expire in 8 hours.

In my application.cfc I had set:

" />

I had incorrectly thought that this timespan would also apply to the COOKIE scope, but it does not.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.