初めてのユーザーだけに私の Web サイトの「ツアー」を提供したいと考えています。JavaScriptでやりたい。つまり、ユーザーが私の Web サイトを一度も見たことがなく、それが初めての訪問である場合、Web サイトの使用方法に関するチュートリアルが表示されるということです。ユーザーが再度アクセスしたり、ページをリロードしたりしても、ツールヒントは表示されません。これは JavaScript Cookie で実行できますか? PHP コードを見つけましたが、とりあえず PHP は避けたいと思います。
<?php
// Top of the page, before sending out ANY output to the page.
$user_is_first_timer = !isset( $_COOKIE["FirstTimer"] );
// Set the cookie so that the message doesn't show again
setcookie( "FirstTimer", 1, strtotime( '+1 year' ) );
?>
<H1>hi!</h1><br>
<!-- Put this anywhere on your page. -->
<?php if( $user_is_first_timer ): ?>
Hello there! you're a first time user!.
<?php endif; ?>
JSで出来ないなら.htaccessで出来ますか?これも見つけました:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^(www\.)?(https?://)?(?!example\.com) [NC]
Rewriterule ^(.*)$ http://example.com/welcome.html [r=307,NC]