Bug #69136 [Asn->Fbk]: Session file empty when session-path on NFS mount

From: Date: Sun, 17 Jan 2016 07:39:25 +0000
Subject: Bug #69136 [Asn->Fbk]: Session file empty when session-path on NFS mount
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198725@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69136&edit=1

 ID:                 69136
 Updated by:         yohgaki@php.net
 Reported by:        maggus dot staab at googlemail dot com
 Summary:            Session file empty when session-path on NFS mount
-Status:             Assigned
+Status:             Feedback
 Type:               Bug
 Package:            Session related
 Operating System:   Ubuntu 14 LTS
 PHP Version:        5.6.6
 Assigned To:        yohgaki
 Block user comment: N
 Private report:     N

 New Comment:

Sorry for the delay, but I couldn't reproduce this on my Fedora23 and CentOS7.
"files" handler is working as it should. 

Do you have this issue still? I think you have some kind of permission issue such as you are writing
session data by multiple user IDs. It wouldn't work with multiple user IDs or root ID.


Previous Comments:
------------------------------------------------------------------------
[2015-03-28 21:14:18] yohgaki@php.net

Locking under shared directory is unreliable. I guess this is the reason why.

Better approach to share sessions across servers is to use databases/caches like
memcached/mongodb/redis/etc.

Anyway, I may look into details...

------------------------------------------------------------------------
[2015-02-27 11:08:28] me at kelunik dot com

Same thing happens with a NTFS partition mounted with under Ubuntu 14.10
ntfs defaults,umask=0000,permissions,uid=1000 0 0.

------------------------------------------------------------------------
[2015-02-27 10:59:29] maggus dot staab at googlemail dot com

1) I dont understand why the session cannot be written, since I checked is_dir, is_writable and
is_readable beforehand. Even setting the dir to "0777" makes it work.

2) when basic things like writing a session doesnt work, I would expect a ERROR instead of a WARNING

------------------------------------------------------------------------
[2015-02-27 10:56:47] maggus dot staab at googlemail dot com

Description:
------------
php -v
PHP 5.6.5-1+deb.sury.org~trusty+1

Test script:
---------------
<?php

$path = '/path/to/a/dir/mounted/via/nfs/';

if (!is_dir($path) || !is_writable($path) || !is_readable($path)) {
    throw new Exception("$path is not a proper dir");
}
//ini_set("session.save_path", $path); // neither this works
session_save_path($path); // nor this does
session_start();

$_SESSION['cnt'] = $_SESSION['cnt']+1;
var_dump($_SESSION['cnt']);

if ($_SESSION['cnt'] > 1) {
    echo "<h1>WORKS</h1>";
    session_destroy();
}
exit();

Expected result:
----------------
on each 2nd request "WORKS" is printed.

Actual result:
--------------
session is not persisted. session file gets created but does not contain any content. therefore
subsequent calls will never echo "WORKS" because session cannot be continued.

with default Ubuntu php.ini a error/warning doesnt show up at all.

After adding 
ini_set("display_errors", "On");
error_reporting(E_ALL);

I get a warning 
"Warning: Unknown: Failed to write session data (files). Please verify that the current setting
of session.save_path is correct (/XX..ZZ..YY/tmp/www/session/) in Unknown on line 0"



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69136&edit=1


Thread (16 messages)

« previous php.bugs (#198725) next »