Solved

Tracking pages within a site

Posted on 2000-03-30
3
166 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
3 Comments
 
LVL 5

Expert Comment

by:nathans
Comment Utility
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 50 total points
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now