Snap Builder Public Codes Library
Snap | Generators | Login | Browse | Search | Enter Code | Export Snap Builder Public Codes Library

 

Category: PHP Codes Library >> Cookies >> Cookie Based Entrance Page


Code Snippet </> Info


Snippet Name: Cookie Based Entrance Page

Description: If your site has an entrance page and you would like that entrance page to ONLY be displayed if a visitor has not seen it, this is what you need.

When someone views your website, a page is called and if the visitor has not visited the entrance page, it will create a cookie on the visitors computer upon page load. If the visitor has already visited your site and the cookie has been created, it will show the main page of your site instead.

Note: Only need to change 4 lines.

Author: Snap Builder <snippets@snapbuilder.com>

Last Modified: 2019-12-14 00:50:18

Language: php

Highlight Mode: html

Copy Codes: Use Free Notepad ++
Bookmark and Share

Snap HTML Code Editor:
Paste the source code, make changes and instantly see it in live preview.
Snap HTML Code Editor


  About Copying
Copied To Clipboard!

<? // #1 Change the cookie name of 'SOMETHING' to your name if(empty($_COOKIE['SOMETHING'])){ // #2 If you renamed 'SOMETHING' cookie, change name below too! setcookie("SOMETHING","vistedmain",time()+60*60*24*30); // #3 This is the main content page path below include("main-content.html"); }else{ // #4 Change the HTML page name for special entrance message page below include("special-entrance-message.html"); } ?>


[ Snippet Options ]

 

© 2002 -  Snap Builder Public Codes Library