PHP file sessions in tmp folder to deal with broken redis sessions

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
rollmeister
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Dec 23, 2016 6:22 am

PHP file sessions in tmp folder to deal with broken redis sessions

Postby rollmeister » Tue Jan 10, 2017 6:39 pm

Hi,

Joomla local filesystem sessions hack tip. I built many sites for someone who resells hosting but the cloud based host has an issue with PHP sessions managed by its redis server, as setup by the server environment in php.ini

We had a problem where when using virtuemart 3, adding or editing cart contents may spawn a new separate cart session and it switched between the first and second cart as it jumped between running joomla on servers on the cluster. Even when sessions are set to database, this problem occurs - maybe virtuemart 3 uses php managed cart sessions?

I added this to the configuration.php after enabling PHP for Sessions in Global Configuration.

Inside the jconfig class...

function __construct() {
session_save_path($this->tmp_path);
ini_set('session.save_handler','files');
}

I checked and it saves a cryptic sessions file in the tmp folder.

I ran a mouse click macro for 8 hours and the was unable to reproduce the problem, so it seems to have worked.

The downside is, if you save Global Configuration in the backend again, you lose this code and I cannot figure out a plugin or what not to help maintain it. Any tips pointing me in the right direction to do this would be appreciated.

Regards,
Rauli

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 17308
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ UK/ S'pore/Jakarta/ North America
Contact:

Re: PHP file sessions in tmp folder to deal with broken redis sessions

Postby leolam » Wed Jan 11, 2017 6:40 am

I am a bit confused why you need to set this in the global configuration.php. You set this on server level in php-settings with

Code: Select all

session_save_handler = files
and in global configuration you set "PHP" which than takes the PHP-settngs (aka 'files) and you set

Code: Select all

session_save_path= /tmp
as well in the PHP-settings so I have some scratching why you need to do this in the configuration.php?

Leo 8)
- Joomla Professional Support Services :https://gws-desk.com -
- Joomla Specialized Hosting Solutions:https://gws-host.com -
- Joomla Professional Web Development :www.gws-studio.com -
- Member Joomla Bug Squad & J-CMS Release Team

rollmeister
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Dec 23, 2016 6:22 am

Re: PHP file sessions in tmp folder to deal with broken redis sessions

Postby rollmeister » Wed Jan 11, 2017 8:36 pm

Hi.

The cloud host this fix is applied this to uses Redis for php sessions. The path is tcp://192.xxxxx or something to store session server side cookies - there is a problem with this Redis server resulting in broken sessions and the host cannot, or will not fix it.

Also, setting this in htaccess as a php flag does not work on this host, maybe because its litespeed and not apache? I dunno
.
The above fix is universal, only needs php to have sessions support and counters all variations in php running as module, cgi etc.

Save sessions path therefore is not always the /tmp folder, could point to a network storage like Redis.

Regards,
Rauli


Return to “Administration Joomla! 3.x”

Who is online

Users browsing this forum: No registered users and 1 guest