|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2015-05-06 06:23 UTC] me at spinov dot net
 Description: ------------ Session is created by Apache user ( apache ) via web interface. Everything is good and nice. Then session is accessed via CLI and here is the problem: If I access session from the same user ( apache ), then everything works. If I access session from root user - I get: PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0 What I've tried: - I can write/read file directly, under any of users mentioned. - I've tried setting mode to 777 on directory/file. - Same code worked in PHP 5.3. No changes to configuration has been made. Test script: --------------- <?php # Create session from web and then try to execute the following script by root user session_id(*session_id_here*); session_start(); Expected result: ---------------- Receive session data in $_SESSION variable Actual result: -------------- PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0 PatchesPull Requests
Pull requests: 
 HistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
I did that as well, but strace doesn't show anything wrong. Here is part of strace with commands: session_id("tsbet8evtiii516f15sk90if87"); session_start(); open("/var/lib/php/session/sess_tsbet8evtiii516f15sk90if87", O_RDWR|O_CREAT|O_N OFOLLOW, 0600) = 3 fstat64(3, {st_mode=S_IFREG|0600, st_size=34530, ...}) = 0 getuid32() = 0 geteuid32() = 0 close(3) = 0 gettimeofday({1434005695, 403384}, NULL) = 0 gettimeofday({1434005695, 403464}, NULL) = 0 open("/var/lib/php/session/sess_tsbet8evtiii516f15sk90if87", O_RDWR|O_CREAT|O_N OFOLLOW, 0600) = 3 fstat64(3, {st_mode=S_IFREG|0600, st_size=34530, ...}) = 0 getuid32() = 0 geteuid32() = 0 close(3) = 0 write(2, "PHP Warning: Unknown: Failed to"..., 176PHP Warning: Unknown: Faile d to write session data (files). Please verify that the current setting of sess ion.save_path is correct (/var/lib/php/session) in Unknown on line 0 ) = 176 Here is file info: # stat /var/lib/php/session/sess_tsbet8evtiii516f15sk90if87 File: `/var/lib/php/session/sess_tsbet8evtiii516f15sk90if87' Size: 34530 Blocks: 72 IO Block: 4096 regular file Device: 801h/2049d Inode: 175886 Links: 1 Access: (0600/-rw-------) Uid: ( 500/silveredge) Gid: ( 500/silveredge) Access: 2015-06-11 10:53:05.318976435 +0400 Modify: 2015-06-11 10:53:04.417976479 +0400 Change: 2015-06-11 10:53:04.417976479 +0400 If I change owner to root, everything works. Here is strace for that case: open("/var/lib/php/session/sess_tsbet8evtiii516f15sk90if87", O_RDWR|O_CREAT|O_NOFOLLOW, 0600) = 3 fstat64(3, {st_mode=S_IFREG|0600, st_size=34530, ...}) = 0 flock(3, LOCK_EX) = 0 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 fstat64(3, {st_mode=S_IFREG|0600, st_size=34530, ...}) = 0 pread64(3, "user-admin|a:11:{s:2:\"id\";i:5;s:"..., 34530, 0) = 34530 mmap2(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb699e000 gettimeofday({1434006320, 576258}, NULL) = 0 gettimeofday({1434006320, 576348}, NULL) = 0 pwrite64(3, "user-admin|a:11:{s:2:\"id\";i:5;s:"..., 34530, 0) = 34530 close(3) = 0 As you see, it looks a bit differently than previous one, cause file is not opened twice. But open call is the same with same result.