Echo Message onto Next Page for 5 Seconds/Timeout Message?

i currently have my site configured so that when a user logs in they are navigated to the home page of my site and they get a welcome message within a session. the bit im having trouble with is finding a way to timeout or close this message or chage the css settings to display:none after 3 seconds.

Can someone please show me how i could add a time out function onto this, heres what i got so far, thanks.

User logs in using html login form, this submits and goes to login.php:

inside login.php i have this:

<?php
if (logged_in()) 
{ 
$_SESSION['login_message']="<div class=\"login-overlay\">
<h1>Login You In Securely</h1></div>"; 
header("Location:home.php");

}
?>

Then inside home.php i have this:

<?
session_start();
if(isset($_SESSION['login_message'] ))
   echo $_SESSION['login_message'];
    unset($_SESSION['login_message']) ;

?>

how can i add a 3 second rule to this so that it only shows for 3 seconds thanks.

1

2 Answers

Use javascript.

setTimeout(function() {
  document.getElementById("message").style.display = 'none';
}, 3000);

javascript hide/show element

You can use jquery,

$(function(){
   setTimeout(function() {
       $("#message").hide('slow');
   }, 3000);
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest