Hi I'm having problems with a web application is working perfectly in my home but when I try to use with diferent networks from a company sessions ends frequenlty. It can occurs anytime even if the users are navigating through the site I think that it occurs specially when everybody are using internet. Finally, this company works with another web application and this is using session cookie created with .aspx and works. Also, I can use my site after close my web browser at home Do you have any idea? this is my code:
function signout(){
    unset($_SESSION['username']);
    unset($_SESSION['id']);
    unset($_SESSION['coa']);
        unset($_SESSION['registrar_usuarios']);
unset($_SESSION['capturar_pedidos']);
unset($_SESSION['salida_materiales']);
unset($_SESSION['alta_clientes']);
unset($_SESSION['alta_productos']);
unset($_SESSION['usuario_cliente']);
unset($_SESSION['cliente']);
    session_destroy();
    session_regenerate_id(true);
    redirectTo('index');
}
/**
 *
 * @return bool, true if all good
 */
function guard(){
    $isValid = true;
    $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
    if((isset($_SESSION['fingerprint']) && $_SESSION['fingerprint'] != $fingerprint)){
        $isValid = false;
        signout();
    }
    return $isValid;
}
function isValidImage($file){
    $form_errors = array();
    //split file name into an array using the dot (.)
    $part = explode(".", $file);
    //target the last element in the array
    $extension = end($part);
    switch(strtolower($extension)){
        case 'jpg':
        case 'gif':
        case 'bmp':
        case 'png':
        return $form_errors;
    }
    $form_errors[] = $extension . " is not a valid image extension";
    return $form_errors;
}
function uploadAvatar($username){
    if($_FILES['avatar']['tmp_name']){
        //File in the temp location
        $temp_file = $_FILES['avatar']['tmp_name'];
        $ext = pathinfo($_FILES['avatar']['name'], PATHINFO_EXTENSION);
        $filename = $username.md5(microtime()).".{$ext}";
        $path = __DIR__ . "/../../uploadscsrnacional/{$filename}"; //uploads/demo.jpg
        move_uploaded_file($temp_file, $path);
        return $path;
    }
    return false;
}
function _token(){
    $randonToken = base64_encode(openssl_random_pseudo_bytes(32));
    //$randonToken = md5(uniqid(rand(), true))." md5";
    return $_SESSION['token'] = $randonToken;
}
function validate_token($requestToken){
    if(isset($_SESSION['token']) && $requestToken === $_SESSION['token']){
        unset($_SESSION['token']);
        return true;
    }
    return false;
}
function prepLogin ($id, $username, $coa,$registrar_usuarios, $capturar_pedidos,$salida_materiales,$alta_clientes,$alta_productos, $usuario_cliente, $cliente){
    $_SESSION['id'] = $id;
    $_SESSION['username'] = $username;
    $_SESSION['coa'] = $coa;
    $_SESSION['registrar_usuarios'] = $registrar_usuarios;
     $_SESSION['capturar_pedidos'] = $capturar_pedidos;
      $_SESSION['salida_materiales'] = $salida_materiales;
     $_SESSION['alta_clientes'] = $alta_clientes;
     $_SESSION['alta_productos'] = $alta_productos;
     $_SESSION['usuario_cliente'] = $usuario_cliente;
     $_SESSION['cliente'] = $cliente;
    $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
    $_SESSION['fingerprint'] = $fingerprint;
    echo $welcome = "<script type=\"text/javascript\">
                            swal({
                            title: \"Welcome back $username! \",
                            text: \"You're being logged in.\",
                            type: 'success',
                            timer: 3000,
                            showConfirmButton: false });
                            setTimeout(function(){
                               window.location.href = 'index.php';
                            }, 3000);
                        </script>";
}
my php.ini in public_html godaddy:
session.cookie_lifetime 43200
session.gc_maxlifetime 43200
And I start my session with this:
<?php
$session_lifetime = 3600 * 24 * 2; // 2 days
session_set_cookie_params ($session_lifetime);
session_start();
PHP Version 5.4.45

 
    