所有页面的首次使用者的网站导览

What is the best way to identify a user to visit a page in a site for the first time. I've written a script which shows a tour of the page. Since tours should be shown only once. I need to know.

For example consider a domain example.com if a user login for the first time i need to show a tour on the '/' page.. When the user navigates to '/page1' i should show the tour for that page. when the user go backs to '/' i shouldn't show the tour. But when user goes to '/page2' i should show the tour on page2.

I could able to find the first time when the user logs in by a single query.! but How can i do that for each and every page. My idea was to make a query to database every time when the user navigates but i know it's not the best way.

Note: Cookies can be used to track anything.

When client logged in, check cookie for pages he has visited.

If the cookie is empty, check database en create new cookie with the pages that de client allready had visited

Further, on every page you check the cookie, if the page is not yet in it, show the tour and add it to the cookie (and the db), else do nothing :)

Ofcourse the db part will only work with registered users. Also do not forgot to store the userid (or something similar) into the cookie and check that too, so that when another user browse your website on the same computer, he still will see the tour!

Something completely else, but might be usefull in your situation is http://notes.xoxco.com/post/36766728425/aware-js-make-your-site-reader-aware

This is a jQuery plugin that keeps track of you visits and change the layout accordingly (eg first time visitor, returning visitor but first time today, ...)

A session would work good. Something like this:

if($_SESSION['first-time'] == TRUE){
    //Do your thing
    //Then, mark first-time as FALSE in the database.
}

When you create an account (assuming that's what you're doing) you flag this as TRUE. Upon their first login, you then mark this as FALSE