J! 4 Session Handler options

Be informed that this forum is not an official support forum for Joomla! 4.0. Any issues regarding Joomla! 4.0 must be reported at https://issues.joomla.org/.

Joomla 4.0 is still in Beta stage. This forum should be used for sharing information about Joomla! 4.0.

Moderator: ooffick

Forum rules
Post Reply
User avatar
sozzled
Joomla! Exemplar
Joomla! Exemplar
Posts: 9172
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

J! 4 Session Handler options

Post by sozzled » Fri May 22, 2020 9:27 pm

As all of us would know, when you create a new J! website (whether we're discussion J! 3.x or J! 4), the default setting for Session Handler = Database.

As all of us know, following the release of PHP 7.0, we've recommended to all users to set Session Handler = PHP in J! 3.x. Not that I particularly understand everything behind this recommendation but the recommendation is based on improving website performance.

You will note that in J! 3.x, the possible values are either Database | PHP.

The following screenshot, taken from a fairly typical J! 3.x website, illustrates the relevant page (I've marked the setting and its possible values with an arrow):
j3SessionHandler-options.png
The following screenshot, taken from a very new J! 4 website, illustrates the analogous page (similarly marked with an arrow to illustrate the possible values I'm discussing):
j4SessionHandler-options.png
You will note that in J! 4, the possible values are either Database | Filesystem. We also should note that J! 4 requires PHP 7.3 as a minimum.

I found a tutorial about this here: https://www.jomsocial.com/blog/joomla-4 ... n-joomla-4. Of significance is the paragraph that reads
PHP Handler :

It is more advanced handler to save the session as compare to the database session handler. It saves the session in by PHP handler, Please note if your server does not support this, do not enable this as it can block the login on site. If you are 100% sure about the PHP handler support, in that case, enable this option.
... but there's no mention of "PHP handler" in the screenshot on that tutorial page or in the J! 4 Global Configuration settings screenshot that I referred to above.

My question is: Does the "Filesystem" option (in J! 4) operate identically to the "PHP" option (in J! 3.x) and, if it does, why was the option renamed from PHP to Filesystem?
You do not have the required permissions to view the files attached to this post.
https://www.kuneze.com/blog
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

 
User avatar
sozzled
Joomla! Exemplar
Joomla! Exemplar
Posts: 9172
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: J! 4 Session Handler options

Post by sozzled » Sat May 23, 2020 12:45 am

It looks like I'll probably have to muddle my way through this, on my own, using educated guesswork as my guide.

OK, so let's strap ourselves into the time machine and look at some of how the recommendation about using Session Handler = PHP/Filesystem (for PHP 7) came into being. In effect, if one can follow some of @mbabker's reasoning, it's because session handling using a database is unreliable: sometimes, stale/expired sessions are not cleaned out. Problems can also escalate if a database is relied upon to handle a large volume of sessions.

What does this have to do with J! 4? Probably not a lot but the different labelling of the option (from "PHP" in J! 3.x to "Filesystem" in J! 4) is confusing.

Just to add to the confusion, in J! 3.x, when you use Session Handler = Database, the setting is stored in the file configuration.php as

Code: Select all

	public $session_handler = 'database';
(There's no change with J! 4, BTW)

However, in J! 3.x, if you use Session Handler = PHP, the setting is stored in configuration.php as

Code: Select all

	public $session_handler = 'none';
(I have to admit, this confused me when I first saw it)

In J! 4, however, if you use Session Handler = Filesystem, the setting is stored in configuration.php as

Code: Select all

	public $session_handler = 'filesystem';
(So it's different ... but is it the same?)

I'm guessing (and maybe I'm guessing wrongly) that they're both "identical" because @mbabker refers to a "PHP filesystem handler" in
mbabker wrote:
Sat May 23, 2020 12:35 am
(from GitHub) I don't know what the JED or forums do for sessions, but the sites that I'm running are all using the PHP filesystem handler and Joomla's conservative caching enabled, they are handling things pretty well in general.
The term "PHP filesystem handler" seems to be significant.

My guess is that whoever defined the value for the Session Handler option as "PHP" in J! 3.x may have taken PHP from "PHP filesystem" and whoever defined the value for the corresponding option as Filesystem in J! 4 may have taken filesystem from "PHP filesystem". Confused? I don't know, I'm just guessing. :o

In any case, I've used Session Handler = Filesystem in J! 4 and it doesn't seem to have had any adverse reaction. 8)

It would be nice if someone could tell me if I've arrived at my conclusion more-or-less correctly or whether I've totally missed the boat. :)
https://www.kuneze.com/blog
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

User avatar
ceford
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: J! 4 Session Handler options

Post by ceford » Sat May 23, 2020 7:32 am

Thanks for the tutorial. As I have been working on Help screens I thought it worthwhile my digging deeper. So here is a code extract:

Code: Select all

From libraries/src/Session/SessionFactory.php

case 'filesystem':
case 'none':
	// Try to use a custom configured path, fall back to the path in the PHP runtime configuration
	$path = $config->get('session_filesystem_path', ini_get('session.save_path'));

	// If we still have no path, as a last resort fall back to the system's temporary directory
	if (empty($path))
	{
		$path = sys_get_temp_dir();
	}

	return new Handler\FilesystemHandler($path);
So filesystem and none are synonymous.

On my Mac laptop I find the file-based session records in /private/var/tmp as sess_t6qqujub1cpuggpd2r6du3nvc0 where the part after sess_ is the session cookie. I guess this could be an issue on shared hosting.

In J4 the Session Save Path and Path to Cache Folder are separate paths but the former is not present in J3. The J4 Help screen has lost most of the content present in J3 - don't know why!

My PHP Info contains:

Code: Select all

Directive		Local Value	Master Value
session.save_handler	user		files
session.save_path	/var/tmp/	no value
I think the only way to understand all this is to write the documentation.

User avatar
sozzled
Joomla! Exemplar
Joomla! Exemplar
Posts: 9172
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: J! 4 Session Handler options

Post by sozzled » Sat May 23, 2020 7:45 am

Thanks, @ceford. It's still only guesswork on my part. There's also another difference between J! 3.x and J! 4 (as you probably noticed).

In J! 3.x, when you select Session Handler = PHP, there's an additional setting in J! 4 (see the area highlighted in the following screen capture):
j4SaveSessionPath.png
I don't know why J! 4 gives people the option to select a specific path for the session data. Maybe it's something that was overlooked in J! 3.x? Is it important? Does it matter if we select a different path other than the fall-back path? What happens if we choose something wrong (or a non-existent path)? Could this additional feature cause problems for novice users? Confusing, isn't it?

I intensely dislike "fall-throughs" in select blocks because I never know what they do. The case clause at line 69 may logically fall-through to line 70 ... or it may do nothing. Anyway, that's some fancy coding that looks a bit too tricky for my liking.

To cut a long story short, I didn't know what to enter for the Save Session Path because there's no useful documentation and because it's too [terrifyingly] new to me. Unless someone explains the purpose of Save Session Path, it's just a waste of screen real-estate. :-\
You do not have the required permissions to view the files attached to this post.
https://www.kuneze.com/blog
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

 

Post Reply

Return to “Joomla! 4 Related”