News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Failed to write session data - 2.0.14

Started by Count, May 24, 2017, 05:41:15 PM

Previous topic - Next topic

Count

After upgrading from 2.0.13 to 2.0.14 and shooting myself in the foot because I was still running php 5.3 I migrated the forum to a new Ubuntu 16.04 LTS server.
Everything seems to be running fine, but error log is filling with these messages: 2: Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/var/lib/php/sessions) and 2: Unknown: Session callback expects true/false return value
I noticed that this issue had been solved for 2.1, so what needs to be done to get rid of it in 2.0.14?

青山 素子

It looks like both messages are related. The configured php session folder doesn't have the right ownership or permissions for php to write into it. You should check that the path that shows up in the error message exists and that the php user can write into it. That should solve both messages.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Count

#2
Well, that's what I thought, too, but the directory was world writable so that shouldn't be a problem. Even when I create a new directory to /tmp with world writable permissions the problem persists.

Edit: And I just realized that I have database backed sessions enabled so that shouldn't even be a problem even if it couldn't write to the directory, right?

青山 素子

That may not necessarily be the case. As long as the session save handler is set to files in the PHP configuration, PHP will still check the session save path when a session starts. You may be running in a configuration where permissions like 777 will not work properly. Personally, I'd see about the ownership of the directory rather than make the sessions directory globally writable.

To test outside SMF, paste the following code into a file and put it on your site. Simply browse to it. If it works, you should just see some text display that mentions an array. If there is an error, you should see it right on the screen.


<?php
error_reporting
(E_ALL);
ini_set('display_errors''1');

session_start();

print_r($_SESSION);
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Count

Hello,

The code returns only this:

Array ( )

The session directory was world writable by default, I didn't touch it. I disabled apparmor in case it was causing the problem, but it also didn't help.

Count

I found a test script from here http://php.net/manual/en/ref.session.php (attached to this message) and when I test with that script, a session file is created to the sessions directory just like it should be. So IMO there's something fishy with the smf installation, but I've no idea what it could be.

Count

OK, a bit of progress. Found this thread and followed the instructions written by sah62 and now the errors disappeared. I did get a few new ones though:

4096: session_regenerate_id(): Failed to create(read) session ID: user (path: /var/lib/php/sessions)
and
session_destroy(): Trying to destroy uninitialized session

After making the abovementioned changes I've only had those errors once, instead of having 10000 errors an hour before. So I can live with that fix. My current Load.php is attached.

Count

...and that error meant that login/logout was not working. So I had to revert to the previous version.

Ideas, anyone?

青山 素子

I'm personally out of ideas in this case, and don't really have time to try and set up a similar situation to debug. Hopefully one of the support specialists or community members will have some advice.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Advertisement: