Solved

Tracking pages within a site

Posted on 2000-03-30
3
169 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
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 50 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

Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to Eclipse 16 116
Web server load balancing technologies and methods 3 85
How to solve ssl error handshake failure alert on IE 1 158
Has my website been infiltrated? 21 63
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

948 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

18 Experts available now in Live!

Get 1:1 Help Now