ini_set("session.lifetime",600);
setcookie("moncookie",valeurducookie, time()+600, "/", ".mondomaine.com",0);


session_start();
if(time() - $_SESSION['timeout'] > 600) // 600 secondes = 10 min
  {session_destroy();
  session_start();
  }
$_SESSION['timeout']=time();

<?php setcookie('pseudo', 'M@teo21', time() + 365*24*3600); ?>  durée 1 an


auto logout

<?php
     session_start();
     $_SESSION['session_time'] = time(); //got the login time for user in second
     $session_logout = 900; //it means 15 minutes.
     //and then cek the time session
    if($session_logout >= $_SESSION('session_time']){
        //user session time is up
       //destroy the session
      session_destroy();
     //redirect to login page
     header("Location:the-path-your-login-page.php");
    }
?> 
