Reputation: 1069
In my php.ini i have the following set:
session.save_handler = redis
session.save_path = "tcp://localhost:6379?weight=1"
But i want to keep that set as it works with this system im using but only thing is when i try create session it gives me errors.. Going off point.
Issue is, im trying to set the save handler then as files ONLY for my login.php and then after that use redis.
I have the following code in my file but doesnt change from redis to files:
session_set_save_handler('files');
session_save_path("/tmp/");
session_start(); // Starting Session
Upvotes: 1
Views: 647
Reputation: 11943
The session_set_save_handler
function doesn't exactly do the same thing as the session.set_handler
configuration directive. The former expects a callable type as its first argument, whereas the latter expects a scalar value as one of the registered handlers in PHP.
What you want is to say ini_set('session.save_handler', 'files')
.
When you set the session.save_path
for the redis
session handler, you should avoid using hostnames that can't be resolved directly through your DNS resolver. That's pretty much anything that you put in /etc/hosts
like localhost
. Instead, try using the IP address that redis is listening on directly, such as 127.0.0.1
. The reason for this is that PHP won't attempt to look at /etc/hosts
directly when resolving the hostname.
Upvotes: 3