Extend PHP session using .htaccess

3

How to extend a session in PHP using .htaccess?

I used this code below:

php_value session.cookie_lifetime 28800
php_value session.cache_expire 28800
php_value session.gc_maxlifetime 28800

But I believe it did not work, so, how can I check if the session I started has this expiration time?

What would be the default cookie expiration time?

I believe that the * .cache_expire code snippet is not about the session, can I remove it from the code?

    
asked by anonymous 30.10.2017 / 19:32

1 answer

1
// Faz o set de duracao em segundos
ini_set('session.gc_maxlifetime', 3600);

// Seta o cookie em segundos
session_set_cookie_params(3600);    

/*
     * Pagina de login
     */
    if($login){
        $_SESSION['CREATED'] = time();
    }

    /*
     * Funcao para verificar o tempo da session
     */
    if (time() - $_SESSION['CREATED'] > 1800) { // Tempo em segundos

        session_regenerate_id(true);    // Regenera o id da session para prevenir o session fixation
        $_SESSION['CREATED'] = time();  // Atualiza o tempo da session
    }
    
31.10.2017 / 11:57