How do I prevent sessions from expiring? I have tried everything and nothing works

73 Views Asked by At

I have literally tried everything and nothing works. Sessions still expire after being away for a very short time.

In my header:

echo '<script>var refreshTime = 6000000; // every 10 minutes in milliseconds
window.setInterval( function() {
$.ajax({
    cache: false,
    type: "GET",
    url: "refreshSession.php",
    success: function(data) {
    }
});
}, refreshTime );</script>';

refreshSession.php:

<?php session_start(); ?>

Also tried:

ini_set('session.gc_maxlifetime', 6000000);
session_start();

Tried this:

session_set_cookie_params(6000000);
ini_set('session.gc_maxlifetime', 6000000);

Tried this (.htaccess):

php_value session.gc_maxlifetime 6000000

I have also tried changing these values within the cPanel PHP options.

I am using GoDaddy and I am not sure if they restrict these or not. Also, if I figure this out, I would like to be able to keep users logged in until they log out instead of specifying a time value.

I would appreciate the help. Thanks.

0

There are 0 best solutions below