I'm not sure why though on localhost
(though not live, as far as I can tell) occasionally session_start();
will generate a new session_id();
. While none of the other threads were able to even figure out what was causing this I quickly determined that session_name('session');
was the cause. However I do not want the session cookie name to be PHPSESSID
.
How do I set the session cookie name without session_name('session');
generating a new session name (or using a second redundant cookie)? I'm currently running PHP 7.3.10.
Editing the php.ini
file and setting session.name = session
did the trick for the issue on localhost
. I am very open to another solution though.
I should note for those dealing with the same issue/different cause that the following:
ini_set('session.cookie_secure', 1);
Should only be run while SSL is active:
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {ini_set('session.cookie_secure', 1);}