Anyone know of a script or code that does this?

dennisyu

Senior Member
Joined
Jan 9, 2010
Messages
870
Reaction score
399
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:

kokoloko75

Elite Member
Joined
Jan 1, 2011
Messages
1,627
Reaction score
1,949
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
 

riekal

Junior Member
Joined
Aug 11, 2009
Messages
122
Reaction score
38
Why not use a cookie with dynamic content insertion?
 

BigGuys

Junior Member
Joined
Nov 30, 2011
Messages
163
Reaction score
621
cookie magic ;)

easily done google if your friend and so is the search button
 

45415

Junior Member
Joined
Feb 5, 2009
Messages
194
Reaction score
93
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
}
 

Tylercoon2010

Newbie
Joined
Mar 30, 2012
Messages
20
Reaction score
3
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); 
?>
 
Top