PHP session with redirect time

Asked

Viewed 525 times

-3

I need help with a PHP user session script with waiting time, so that if there is no activity on the page it is redirected to an output page.

1 answer

1

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

<?php

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

?>

This way, every page that needs the user session, you should check if there is an active user session, thus:

<?

    if(!isset($_SESSION)){

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

?>
  • is automatic friend? in real time?

  • I’m a little confused about your "automatic", you mean that when you run out of time already redirect the page, or if the user tries to go to a page that needs a session and it has already run out, then you would have to redirect?

  • javascript

  • real-time

Browser other questions tagged

You are not signed in. Login or sign up in order to post.