Set Joomla Session Handler to PHP instead of Database

Here is the relevant transcript for this video:

A tutorial showing how to set Session Handler to PHP.Hey there, Joomla fans. Tim Davis here. I'm a Joomla fan too. Thanks for tuning in to this week's Maintenance Monday Live Stream.

I missed last week. Things got super busy. But I'm doing one today so remember, subscribe to the channel and ring the bell to receive updates and notifications of new live streams and tutorials.

Today we're going to look at what to set the Session Handler to on our Joomla sites. So let's head on over to the screen and we will take a look at what we're talking about here.

I can't really zoom in like I do when I make a tutorial so we're just down here at the bottom of the screen in the Configuration File. Now to get there we go to System, Global Configuration, and then click on the System tab. You might see Site first, but click on System.

So basically, the Session is information that is set when you log in saying, "Hey Tim is logged in to the site, and so we will talk to Tim's computer." And in layman's terms there's a permission set and connections. Then once that Session is set you have in this case, 15 minutes to be doing something on the site: saving it or closing a window or calls to the server, and each time you do something the Session is reset.

If you leave - in this case the way this site is set - after 15 minutes and do nothing, then the Session expires, so that if someone came walking along to go on your computer they won’t be able to get on; unfortunately, that also includes you.

There are two options right now in Joomla. This is a Joomla 3.7.5 site and there are two options of where to store the Session information.

Probably by default when you set up your Joomla site it is set to Database. So, the information that records that your visit is active is stored right in your Joomla database, and that works great. But if your server or your web host is set up for it - and on Cybersalt Hosting it is set up for this - if you switch from Database to PHP then your Session information, instead of being sent to the database and a hard drive spinning, or maybe you have an SSD drive on your servers or your host has SSD drives - instead of going to a drive, the Session information is stored in a file right on the server. That's always faster. When you can write to a file that's running in the memory on the server instead of saving it to a hard drive then that is faster. And especially some people will run Joomla but the database is on an entirely different server. So, this can speed up things.

Now the reason I haven't saved this yet is because if your web host is not set up to handle Sessions through the PHP method or through a file method then if you save this you might get locked out of your Joomla site. So don't try this unless you're sure that you can switch up the PHP - maybe you have sites on the same server and you're working on different ones, or until you are sure that you can go into your control panel for your web hosting to go and edit this right in the file. Now, before I save this, we'll just look how to do that.

In this tab, here's the file manager for this web hosting account that I have this Joomla site on and basically what I've already done in the file manager in this Control Panel, is clicked on file manager and then in the root folder that Joomla is installed you want to find the configuration.PHP file. Then when you find that you want to edit it.

Now I'm not going to open this right now because I can't blur out password information on a Live Stream, but what I will show you is this. If you save your configuration file after switching to PHP for your Session Handler and your site doesn't work, go into the file space, go into configuration.PHP, find the line in your configuration.PHP that says "public session_handler" and what you will see is this: once you switch to PHP the handler equals "none." You would think they would say PHP but it says "none" because I think that's a carry-over from some other versions, because the option used to be between database or none. So, when you see public session _ handler = "none" if you want to switch back, switch that to "Database" and then save your file in your file manager and then your Joomla site will come back online. So let's just go back here because I want to show you what happens when you do change this.

One another thing. Remember back up your site. I've got a tutorial on how to do that which you can access here. Backup your site regularly because as you're tinkering around with this stuff something can happen at any time; you never know.

Alright, so now we're logged in to the backend of the site here still, Session Handler was at Database, we switched it to PHP, now I'm going to save it. When I save it, I'm going to get kicked out of the back end of the site and that's why we wanted to make sure that you have access to the file manager on your web hosting because if the screen had just gone black then I would have been in a bad way. But basically, when you switch the method to where your sessions are stored, you have to create a new session - you're logged out.

So I can log into here and that will take us back into the site and we can go System, Global Configuration, and just for maintaining or perhaps even it's more just setting up our site here we now have changed Session Handler from Database to PHP which is the "none" method, and there it is and it stuck.

So that's just something that you can do to give yourself a little bit of boost of performance in your Joomla site and a good way to set it up if your web hosting is set up for that.

So as always, enjoy your Joomla sites and God bless you.

Don't forget to subscribe.

Top