Our site www.viart.com site is operated by latest Viart Shop 5 with default Clear design
Topic Information
hcanning
hcanning
Hi,
 
Any ideas on how to tweak the script at http://php.about.com/od/finishedphp1/ss/last_visit.htm
 
to pull the users name from the viart database so that you could say Welcome Back John i.e Welcome Back 'Registered Users Firstname'.
 
Would be nice to personalise the shopping experience like amazon and ebay etc... do it.
 
Thanks
 
code
<?php
if(isset($_COOKIE['AboutVisit']))
{
$last = $_COOKIE['AboutVisit']; }
$year = 31536000 + time() ;
//this adds one year to the current time, for the cookie expiration
setcookie(AboutVisit, time (), $year) ;
if (isset ($last))
{
$change = time () - $last;
if ( $change > 86400)
{
echo "Welcome back! <br> You last visited on ". date("m/d/y",$last) ;
// Tells the user when they last visited if it was over a day ago
}
else
{
echo "Thanks for using our site!";
//Gives the user a message if they are visiting again in the same day
}
}
else
{
echo "Welcome to our site!";
//Greets a first time user
}
?>
 
Last modified: 11 May 2010 2:12 PM
 
benshanks
benshanks
setCookie/getCookie could be modified to include user login details / username, not ever checked to see it is already present in viart though, accessing the DB to retrieve user details based on locally cache info, sounds very risky
 
Regards
Ben