Untitled

 avatar
unknown
plain_text
6 months ago
725 B
2
Indexable
<html>
    <head>
        <title>Visited Date_Time Using Cookie</title> 
    </head>
    <body align="center">
        <form action="dateTime.php" method="post">

        
        <h1>Welcome to the page
        <p>
            Last Visited:
            <?php echo "lastvisited";
            ?>
        </h1>
        </p>
    </form>
    </body>
</html>


<!-- dateTime.php  (php file external ) -->

<?php 
    if(isset($_COOKIE['last_visited'])){
        $last_visited=$_COOKIE['last_visited'];
    }
    else{
        $last_visited="This is yout first visit";
    }

    $currentDateTime=date('Y-m-d H:l:s');
    
    set cookie('last_visited',$currentDateTime,time()+365*24+60+60);
    ?>
Editor is loading...
Leave a Comment