Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: touch(): Utime failed: Permission denied

Tags:

php

touch

I am writing the session to a temporary file as follows:

if ($_SESSION['user_login_status'] == 1)
        {
        touch("tmp/access-" . session_id()); 
        }

I have the following permissions set on tmp just to test it is working (I will modify permissions to be more restrictive as I test):

drwxrwxrwx+

I receive the following error:

Warning: touch(): Utime failed: Permission denied

Any thoughts? Everything I have googled thus far says check the permissions (done) or is related to a wordpress error which I am not running. Thanks!

like image 575
6paq Avatar asked Mar 21 '14 19:03

6paq


3 Answers

I ran into the error and just removed the underlying files and the error went away...

like image 76
Chris Stryczynski Avatar answered Nov 03 '22 21:11

Chris Stryczynski


It seems that the permissions on the directory are not the problem, rather the "access-" . session_id() seems to already exist and it's permissions are so that the PHP process can't change it's Utime. Check if the file "access-" . session_id() exist, if so remove it and run the script. If you do not receive an error check if the file "access-" . session_id() was created and what it's permissions are. If they are not correct try to chmod the file directly after creating it with touch.

like image 31
Reinoud van Santen Avatar answered Nov 03 '22 22:11

Reinoud van Santen


I had the same error message show up (but a different code snippet). What solved it for me was to change the owner for the file, i.e. chown uname:uname filename.

like image 5
Hamman Samuel Avatar answered Nov 03 '22 22:11

Hamman Samuel