Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP session permission problem

I'm trying to initialize a session but i get this error:

Warning: session_start() [function.session-start]: open(/tmp/sess_7af3ee9ec1350680bedcf63833d160bd, O_RDWR) failed: Permission denied (13)

The session.path is set to /tmp with 777 perms.

I try to edit the session.path to "0;777;/tmp" but the session files are created with the wrong permissions(only write).

I'm using PHP 5.2 on apache2 and ubuntu 9.10. Any ideas?

like image 405
Daniel Avatar asked Jan 13 '10 17:01

Daniel


2 Answers

Please verify that the permissions of /tmp really are xx777

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$s = stat('/tmp');
printf('%o', $s[2]);
file_put_contents('/tmp/phptest1234.txt', 'test');
unlink('/tmp/phptest1234.txt');

edit: next try, umask

<?php
echo ' php-umask: ', sprintf('%o', umask()), "\n";
echo ' exec-umask: ', exec('umask'), "\n";
like image 62
VolkerK Avatar answered Oct 21 '22 18:10

VolkerK


It seems like you do not have permissions to write to the tmp directory, you need to give it permissions to save a file.

like image 24
Anthony Forloney Avatar answered Oct 21 '22 19:10

Anthony Forloney