i am trying to change default session cookie parameters. To store the session data i am using mysql and session_set_save_handler()
this is the constructor of the class Session
public function __construct(){
// Instantiate new Database object
$this->db = new Database;
// Set handler to overide SESSION
session_set_save_handler(
array($this, "_open"),
array($this, "_close"),
array($this, "_read"),
array($this, "_write"),
array($this, "_destroy"),
array($this, "_gc")
);
// Start the session
session_set_cookie_params(time() + (86400 * 30),"/","",true,true);
session_start();
}
If the line session_set_cookie_param()
is set after session_start()
i have this error
PHP Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active
before the session_start()
i have no error but no cookie is set. And when the line is removed the session cookie is set successfully with default php data "PHPESSID" and exptime = Session.
The session_status()
right before the session_start()
line is equal to 1 (PHP_SESSION_NONE)
If i set params before session_set_save_handler()
no cookie is set.