In my PHP application users are able to log in but new users are not able to register due to the following error after PHP 7 upgrade.
The error is : PHP message: PHP Warning:  ini_set(): A session is active. You cannot change the session module's ini settings at this time in
I am hosting my server on Cloudways. Could anyone help me with that. I am trying to find the solution for two days.
Functions.php code :
<?php 
session_start();
// server should keep session data for AT LEAST 1 hour
ini_set('session.gc_maxlifetime', 1209600); 
// each client should remember their session id for EXACTLY 1 hour
session_set_cookie_params(1209600);
function logged_in () {
    if (isset($_COOKIE['usnm']) || !empty($_COOKIE['usnm']) && isset($_COOKIE['usid']) || !empty($_COOKIE['usid'])) {
        $_SESSION['user_id'] = $_COOKIE['usid'];
        $_SESSION['username'] = $_COOKIE['usnm'];
        return true;
         setcookie("usnm",$mobile, time() + (10 * 14 * 24 * 60 * 60));
         setcookie("usid",$_SESSION['user_id'], time() + (10 * 14 * 24 * 60 * 60));
          setcookie("usnm",$user['mobile'], time() + (10 * 14 * 24 * 60 * 60));
         setcookie("usid",$user['userid'], time() + (10 * 14 * 24 * 60 * 60));
    } else {
        return false;
    }
}
function redirect_to ($url) {
    @header("Location: {$url}");
}
?>
 
    