webcodebase.com Snippets database & Pastebin

Display a different page if the user is not unique (based on cookies)

Submitted on 13/12/2008
Authors Comment: Ever wanted to show a different page if a user is not unique? Or perhaps protect a user from reloading the page? This script will do all of that and more!. Everything is commented with great detail.
How to use:

Code


<?php
/*
Example for Display a different page if the user is not unique (based on cookies)
*/

// Script name
include("ip.php");

if(UNIQUE == true)
{
echo "User is Unique";
}
else
{
echo "User is NOT Unique";
}
?>
Download Snippet:
Snippet:

  1. <?php
  2.         /*
  3.        
  4.         * Display a different page if the user is not unique
  5.         * but will show the same page after a while.
  6.         * Cookie based
  7.        
  8.         *** [ Configure ] ***
  9.         */
  10.        
  11.         /*
  12.         * Time in seconds for the website to change after first load;
  13.         * You can also use (60*60*7) instead of the value
  14.         * Current Value: 24h
  15.         */
  16.         $time   =       86400;
  17.        
  18.         /* Check if the cookie is already set */
  19.         if(isset($_COOKIE['Expire'])
  20.         {
  21.                 /*
  22.                 * If it is, then the user is NOT Unique
  23.                 */
  24.                 define('UNIQUE',false);
  25.         }
  26.         /* If it is not set, then we better set it! */
  27.         else
  28.         {
  29.                 /*
  30.                 * The user is unique
  31.                 */
  32.                 define('UNIQUE',true);
  33.                
  34.                 /*
  35.                 Lets get the time the cookie will be expired
  36.                 */
  37.                 $expire = time() + $time;
  38.                
  39.                 /*
  40.                 Set the cookie
  41.                 */
  42.                 setcookie("Expire",$expire,$expire);
  43.         }
  44. ?>

 

Comments:

  1. .mvajtwajqoo | December 11, 2008 at 18:47

    fQIr6i <a href="http://ackaszjweszb.com/">ackaszjweszb</a>, [url=http://bmqhzonxntjy.com/]bmqhzonxntjy[/url], [link=http://jsearvyochxc.com/]jsearvyochxc[/link], http://ezoefsbqguyp.com/

  2. .IRLspam | December 11, 2008 at 18:47

    So you what?

  3. .roehctop | December 11, 2008 at 18:47

    EemmLq <a href="http://tuqkgsktodvp.com/">tuqkgsktodvp</a>, [url=http://ebkhotkqwlsd.com/]ebkhotkqwlsd[/url], [link=http://lfremdvlrwft.com/]lfremdvlrwft[/link], http://oukmcdyzotnn.com/

  4. .cnzdtgodihd | December 11, 2008 at 18:47

    LpBYh8 <a href="http://thzmfttxnhrd.com/">thzmfttxnhrd</a>, [url=http://vxipkedktcwh.com/]vxipkedktcwh[/url], [link=http://khllbnpoakzr.com/]khllbnpoakzr[/link], http://adxaptawrrfa.com/

  5. .qwmpcpuzze | December 11, 2008 at 18:47

    hYPl97 <a href="http://aomhglpnrttd.com/">aomhglpnrttd</a>, [url=http://ncpbavvgoqlo.com/]ncpbavvgoqlo[/url], [link=http://efloualuvkzg.com/]efloualuvkzg[/link], http://wyulwdrebpce.com/

  6. .hxlotnfooie | December 11, 2008 at 18:47

    V8hogk <a href="http://bhtmynswinjb.com/">bhtmynswinjb</a>, [url=http://tvvnvwxadxhv.com/]tvvnvwxadxhv[/url], [link=http://disxnfecdjhm.com/]disxnfecdjhm[/link], http://kiozissrhfcy.com/

  7. .pssarylndd | December 11, 2008 at 18:47

    g8iUR0 <a href="http://erdrcqofpnia.com/">erdrcqofpnia</a>, [url=http://zwdpzmbvsqxw.com/]zwdpzmbvsqxw[/url], [link=http://qcnlgnspkiuz.com/]qcnlgnspkiuz[/link], http://ubpjjbbkiden.com/

  8. .zasfylgszk | December 11, 2008 at 18:47

    xgff8p <a href="http://aigrdyeosass.com/">aigrdyeosass</a>, [url=http://qpbswnfuxxig.com/]qpbswnfuxxig[/url], [link=http://sygfoukxwadi.com/]sygfoukxwadi[/link], http://dbjxbtwamopx.com/


New Comment:
Name:
Comment:








Latest News

  • 30/12/09
    Webcodebase is BACK & New updates.
    Hello, Because of a jackass of a friend the main files for Webcodebase was deleted. I Thought everything was lost until i found a backup folder on my old linux box, so i restored WCB Back to its original state. The staff will continue posting snippets and fighting spam. We will also start releasing tools that web masters can use to check their scripts for vulnerabilities. These scripts will have special stars next to them and the "STAFF" tag. Please use these on your own systems only, we are NOT responsible for any damage they may do. We release them purely for educational purposes only! Thanks, Head of WCB, Arne AKA Cypher....
    [Read More]