I created a login page with codeigniter,but i get the php message.
Message: ini_set(): A session is active. You cannot change the session module\'s ini setting
This is really working for me
if (!isset($_SESSION)) {
// server should keep session data for AT LEAST 24 hour
ini_set('session.gc_maxlifetime', 60 * 60 * 24);
// each client should remember their session id for EXACTLY 24 hour
session_set_cookie_params(60 * 60 * 24);
session_start();
}
so you do start your session after calling ini_set and session_set_cookie_params etc
Message: ini_set(): A session is active. You cannot change the session module's ini settings at this time
I had same error message sometime ago , By default Code-igniter will write to file (C:\xampp\tmp) in my case. But I want it to write to database instead.
In your autoloader you might have had something like this:
//:::::$autoload['libraries'] = array();
//'session', this mean start session ini_set()
$autoload['libraries'] = array('session', 'database');
By default setting in the config/config.php session configurartion look like this:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
The documentation stated that to use database instead of file you should first create a table in application database.
CREATE TABLE IF NOT EXISTS `ci_sessions` (
`id` varchar(128) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL,
KEY `ci_sessions_timestamp` (`timestamp`)
);
Go back to the config/config.php and change $config['sess_driver'] = 'files';
to $config['sess_driver'] = 'database';
Like so I thought everything should be fine but I got the error Message: ini_set(): A session is active. You cannot change the session module's ini settings at this time
My Solution was to first run the session_destroy();
Then change session name and table name
My config look like this :
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'newname_session';
$config['sess_expiration'] = 72000;
$config['sess_save_path'] ='newname_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
Save everything and after refresh the page all cleared, no error message showing
You can handle this issue by only running the command when it's needed like this:
if (!isset($_SESSION)
&& !headers_sent()
) {
session_start();
}
You don't need this line in admin.php
session_start(); //need to call PHP's session object to access it though it
When you load the session library, its constructor does this for you.
The message means that you have started a session with session_start()
in which further down in the code you are using ini_set()
to manipulate the session module. If you are manipulating the session module, it should be done before a session is started and active.