2

サイトのページに初めてアクセスするユーザーを特定するための最良の方法は何ですか。ページのツアーを示すスクリプトを作成しました。ツアーは一度だけ表示する必要があるため。私は知る必要がある。

たとえば、ユーザーが初めてログインして「/」ページにツアーを表示する必要がある場合は、ドメインexample.comについて考えてみます。ユーザーが「/ page1」に移動すると、そのページのツアーを表示する必要があります。ユーザーが「/」に戻ったとき、ツアーを表示するべきではありません。しかし、ユーザーが「/ page2」に移動すると、ページ2にツアーを表示する必要があります。

ユーザーが1回のクエリで初めてログインしたときを見つけることができました。しかし、どうすればすべてのページに対してそれを行うことができますか。私の考えは、ユーザーがナビゲートするたびにデータベースにクエリを実行することでしたが、それが最善の方法ではないことはわかっています。

注:Cookieは何でも追跡するために使用できます。

4

2 に答える 2

4

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, ...)

于 2012-12-06T08:56:33.193 に答える
1

セッションはうまくいくでしょう。このようなもの:

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

アカウントを作成するとき(それがあなたがしていることであると仮定して)、これにフラグを立てますTRUE。彼らの最初のログイン時に、あなたはこれを次のようにマークしますFALSE

于 2012-12-06T08:54:05.950 に答える