I am using the following code to track a session.
Code: Select all
<?php
session_start ();
?>Code: Select all
<?php
if (!IsSet($_SESSION['visit_count'])) {
echo "<h2>Welcome to Inspired-Evolution.com!</h2>";
$_SESSION['visit_count'] = 1;
}
else {
$visit_count=$_SESSION['visit_count'] +1;
echo "<h2>Welcome Back! I see you have visited $visit_count times</h2>";
$_SESSION['visit_count'] = $visit_count;
}
$self_url = $_SERVER['PHP_SELF'];
$session_id = SID;
if (IsSet($session_id) &&
$session_id) {
$href ="$self_url?$session_id";
}
else {
$href = $self_url;
}
?>http://www.inspired-evolution.com/index.php
The problem is if you close the browser window and go to the site again, your treated as a first time visitor, your only tracked if you hit refresh or navigate away and back to the home page. Is this how it is supposed to work? I was wanting some code that would recognize you after you leave completely and come back. Can this be done with PHP?
thanks!