[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Tracking pages within a site

Posted on 2000-03-30
3
Medium Priority
?
176 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

873 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