you think this is sooooo easy. well,.. yes, if you do alot of brainstorming or you are someone who makes logical results 😉
well.. let's introduce to "lastivisit"..
i have an field LASTVISIT in USERS table in mysql. lastivisit only works for registered users (the users in USERS table).
solution will be used with cookie. you must know, that user can come to your site (lastvisit echoes), user refreshes the site (lastivisit must be the same as the one before)...
and i don't know how to code everything 😢
please help me!!!
this is what i did so far:
<code>
if (isset ($cookies [$func->cookie_lastvisit]))
{
$__lastvisit = $cookies [$func->cookie_lastvisit]);
// if user was here recently
if (($time - $lastvisit) > $func->online_timeout)
setcookie ($cookies[$func->cookie_lastvisit], $__lastvisit, 0, "/");
// if he wasn't
else
setcookie ($cookies[$func->cookie_lastvisit], $__time, 0, "/");
}
// if lastvisit doesn't exists
else
{
$lastvisit = date ("Y-m-d G:i:s");
$result = mysql_query ("UPDATE users SET lastvisit='". $lastvisit ."' WHERE userid=". $__userid) or
die (mysql_error ());
setcookie ($cookies[$func->cookie_lastvisit], $__time, 0, "/");
unset ($lastvisit);
}
</code>
thanks for helping 😉