0

I am creating a simple login page using session and cookie. If the user login on system and if the user don't do anything on the page,it will redirect to login page again after 1 minutes using php What I have tried so far is attached below.

Login.php

<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST'){

    $username = $_POST['uname'];
    $password = $_POST['pass'];

    if($username == "kobi" && $password == "123"){
        $_SESSION["uname"]=$username;
        setcookie("user", $username, time() + (60)); 
        header('location:welcome.php');        
    }
}
?>

welcome.php

<?php
    session_start();    
    echo "User Name " .  $_SESSION['uname'] . ".<br>";    
?>
Ajith
  • 2,476
  • 2
  • 17
  • 38
creative one2018
  • 131
  • 2
  • 11

1 Answers1

-1

I think you should change the setcookie time function.

as your function was

setcookie("user", $username, time() + (60)); 

So remove the time second as round brackets

setcookie("user", $username, time() + 60);

Hopefully this works.