PHP session with redirection time

0

I need help with a user session script in PHP with timeout, so if there is no activity on the page it will be redirected to an exit page.

    
asked by anonymous 31.01.2017 / 09:04

1 answer

0

After the user logs in, you can enter the following code snippet:

<?php

    session_start();
    session_cache_expire(1800); //o tempo é medido em segundos

?>

In this way, every page that needs the user session, you should check if there is an active user session, like this:

<?

    if(!isset($_SESSION)){

        //aqui você aplica o redirecionamento
        header("Location: ".$enderecoPagina);
    }

?>
    
31.01.2017 / 11:10