Session management in ColdFusion
Sessions, or requests that a single user makes to a server, are one way to measure your Website's traffic. They are unique to each visitor, and although sessions are inherently anonymous (no personal identification is required), they can be useful in tracking and reporting traffic as well as in personalizing your site. Sessions can be used to generate display preferences, such as background colors or font faces, as well as content preferences, such as feature stories, local news, or stock quotes. Once determined, such preferences will persist through every page on the site.
Sessions start and end when the user enters and exits, respectively. A session may also end if the browser is idle for a significant amount of time. To track visitors, certain variables are assigned to a user -- perhaps a unique userid is associated with the contents of a shopping cart. That userid is passed along to every page the user views so that the displayed cart is accurate. Sessions can also be used to deliver dynamic content based on a visitor's profile, assuming a voluntary registration form has been completed.
Suppose a visitor to a portal site selects local news as a primary area of interest when filling out a registration form. That information could be used to generate navigation links throughout the site. Likewise, if a visitor enters a preference for stock quotes, every navigation template could incorporate a link to stock quotes. The site is not only personalized but also remains personalized throughout the session.
Session variables versus application variables
The focus of this article is on sessions and session-based variables, not on application variables. It's important to differentiate between the two. The goal of session variables is to maintain the state of a site without setting multiple cookies or making numerous calls to a database. The most significant difference between session variables and application variables is in scope. As stated earlier, sessions are attached to each unique visitor. Application variables are attached to an entire site or application.
You can set or call session variables anywhere in the site and they will be applicable to one specific visitor. Conversely, application variables are set once on the server and can be called anywhere in the site, regardless of the visitor. Consider setting an application variable for a copyright stamp to be displayed on all navigation footers. The first step is setting a variable called copyrightdate to 2000 in the Applicaton.cfm page. You can include that value on any page within the site by referencing #application.copyrightdate#.
<html> <body> Copyright #application.copyrightdate#, all rights reserved. </body> </html>
That would output the following to the browser:
Copyright 2000, all rights reserved.
You can think of application variables as small server-side includes (SSIs) that exist independently of session variables. They are invaluable in maintaining sites where small pieces of content change frequently, and advantageous because they place less load on the server than multiple SSIs.
Tracking sessions in ColdFusion
Allaire ColdFusion gives you three ways
Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.
Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.
Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.







