Looking at global question that sounds like "How can I make the user surfing my site better?" I can three important answers:
- Obvious navigation aka main menu. Especially, when you have a lot links there. Solutions may vary: plain links, tabs, drop-down menus etc.
- Using breadcrumbs. People should be able to go level up (though it is not always "Back" action).
- History. Implementing custom history can be useful, say for e-shop -- to show previously viewed stuff in reliable and handy way.
Please note that history is the task #3, not 1 or 2. Reason of explaining all this is that your History should not serve for #1 (definitely) and #2 (can be sometimes).
Basically history can be stored in two ways: for current session only (for any user) and between sessions (typically for logged in users).
Simplest way to implement the first way is to use ColdFusion sessions. When creating session (onSessionStart() if using Application.cfc) initialize the container, I would use the array.
Consider the following samples:
<cfscript>
session.history = [];
</cfscript>
When user opens new page (even in new tab -- which starts new browser history) -- push the page information into the container (page should contain link and kind of label at least):
<cfscript>
page = {};
page.link = "/index.cfm?product=100";
page.label = "Product Foo";
ArrayAppend(session.history, page);
</cfscript>
Finally, somewhere in page template loop over this array and display the links:
<cfloop array="#session.history#" index="page">
<div><a href="#page.link#">#HTMLEditFormat(page.label)#</a></div>
</cfloop>
Obviously, if you want to show the Previous/Next links, you should modify the way of storing the history, maybe keep current page position (in array) too -- to pick the previous and next elements. Though as a User I would not find such feature much useful.
Finally, if you want to store the history between sessions, simply write this dataset in the database identified by user id (fk) and restore it when user logs in.
Please remember, that it is highly recommended to use locking when reading/writing.