Anyone know of a script or code that does this?

dennisyu

Senior Member
Joined
Jan 9, 2010
Messages
872
Reaction score
408
Obviously you could pay someone to code such a thing, shouldn't be too hard. But i'm curious if anyone knows of something that's already out there.

Basically, when a user leaves your landing page and comes back-- i want it to display different html. I believe it's a javascript cookie thang.
 
Last edited:
You should log IPs in a database, with an integer (0 if IP doesn't exists, 1 if already visited).
Then, if integer = 1 he'll be redirected to Page1, else to Page0.

Don't know for the code, sorry... :)

Beny
 
Why not use a cookie with dynamic content insertion?
 
cookie magic ;)

easily done google if your friend and so is the search button
 
Something likes this.

To set the cookie:
PHP:
$expire = time() + 3600*24; // 24 hours
setcookie("some_name", "1", $expire, "/"); // name=some_name, value=1, expires after $expire seconds, path = / (whole domain)
To check, if the user has cookie:
PHP:
if ( isset( $_COOKIE["some_name"] ) ) {
    // redirect or show the code for returning users
}
else {
    // redirect or show the code for first time users
}
 
Make this your index.php page:

PHP:
<?php 
if(isset($_COOKIE['hasVisit'])){
include("hasvisited.php");}else{ include("nevervisited.php");} ?>

Then on nevervisited.php put this:
PHP:
<?
$expiry = 60 * 60 * 24 * 365 * 10 + time();  setcookie('hasVisit', 1, $expiry); 
?>
 
Back
Top