Extend session in PHP using .htaccess

Question:

How to extend a PHP session 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 didn't work, by the way, is there any way to check if the session I started has this expiration time?

What would be the default session (cookie) expiration time?

I believe that the *.cache_expire code snippet has nothing to do with the session, can I remove it from the code?

Answer:

// 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
    }
Scroll to Top
AllEscort