?
Solved

Tracking pages within a site

Posted on 2000-03-30
3
Medium Priority
?
174 Views
Last Modified: 2013-12-24
I need some code or a custom tag that will track the exact page within a Web site where the user left off so that the next time he/she visits the site they are returned to the page they were on when they last left the site. For example, if I have a 50 page site which is intended to be viewed in order (page 1, 2, 3,...) and I get up to page 25 and the leave the site and come back to it the next day, that once I log in I will be returned to page 25, which is where I left off.
0
Comment
Question by:cfcode
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:nathans
ID: 2670892
What I would do is set a cookie

either
1. for the user and keep track of where they are in a database.
2. or let the cookie say where the last page was by setting the cookie with the page number or something.
0
 

Accepted Solution

by:
bdemarzo earned 100 total points
ID: 2674412
If a user is actively logging off, store the page number in a cookie using <CFCOOKIE ...>. When they log back in, retrieve the cookie value and go to that page.

If the user is not actively logging off, you need to set the cookie at the top of each page, to ensure the cookie points to the page. Then use some logic - if the user re-enters the ordered pages, and they have a cookie defined, go to the appropriate page, otherwise go to page 1. (To do this effectively, the FIRST page of your ordered pages shouldn't be page 1; rather, it should be a page of pure CF code that just redirects to the appropriate page.)

Example:

On each page (page1.cfm, page2.cfm, etc.), insert the following:

<cfcookie name="pagenum" value="1">

Make sure you set the "value" to the page number.

When the user clicks the link to start viewing your page list, go to a page that will check to see if this is a new visit or a returning visit (say, "page0.cfm"):

<cfif IsDefined("cookie.pagenum")>
  <cflocation url="page#cookie.pagenum#.cfm">
<cfelse>
  <cflocation url="page1.cfm">
</cfif>

Not the most glorious solution, but it should work.
0
 

Author Comment

by:cfcode
ID: 2691141
bdemarzo forgot to mention that in the cfcookie tag you need to set the EXPIRES attribute to "never" or to "365" or to some date in the future or else the cookie will expires when the browser is closed. This is a critical issue as the application will not work as intended if the expires attribute is ommitted.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question