Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    88
    Thanks
    24
    Thanked 0 Times in 0 Posts

    User Last visited script help

    I have this piece of code but its not working for me and cannot find the answer as im currently learning php...

    the code should show when I/user last visited the website with a cookie set, heres what i have...

    PHP Code:
    <?php

    if(isset($_COOKIE['LastVisit']))

    {
    $last $_COOKIE['LastVisit'];

    }

    $year 31536000 time() ;

    setcookie(LastVisittime (), $year) ;

    if (isset (
    $last))
    {
    $change time () - $last;
    if ( 
    $change 86400)
    {
    echo 
    "Last visit was"date("m/d/y",$last) ;

    }

    ?>
    Any help is hugely appreciated.


    Kind regards,
    paffley

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,180
    Thanks
    23
    Thanked 602 Times in 601 Posts
    Your missing a close bracket. The if ( $change > 86400) keeps the echo from executing. LastVisit needs to be in quotes.

    A little lean up and we have
    PHP Code:
    <?php
    if(isset($_COOKIE['LastVisit']))
    {
        
    $last $_COOKIE['LastVisit'];
    }
    $year 31536000 time() ;
    setcookie('LastVisit'time (), $year) ;

    if(isset(
    $last))
    {
        echo 
    "Last visit was" date("m/d/y"$last);
    }

    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •