when I uploaded the script to the server I got this error
Warning: Unknown: open(/tmp/sess_58f54ee6a828f04116c2ed97664497b2, O_RDWR) failed: Permission denied (13) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
the error appeared when I call session_start();
although I set the permission of /tmp folder to 777 .
Additionally, you may want to use
ini_set('session.save_path', '/dir/here');
assuming you have access to this function. The other ways suggested are valid.you will need to change your
session.save_path
php.ini directiveYou can do that using
session_save_path
I've just had exactly the same problem with one of my PHP scripts and I was like what did I break 'cos it worked perfectly the day before and I'm running it from my own local Puppy Linux machine so it's not even a host or anything.
The only thing I'd been doing before that was trying to get Java to work in the web browser, so some how I'd managed to get Java to work but broke PHP - oops!
Anyway I did remember that whilst trying to get Java to work I had deleted the contents of the /tmp folder to wipe anything out that may be causing a problem (it actually turned out with Java I was using the old plugin oij with the new Firefox)
To solve this problem I opened up Rox File Manager, went to the / folder and right clicked on the tmp
folder -> Mount Point 'tmp' and clicked properties
.I noticed the permissions were set as Owner - Read, Write, Exec, but Group and World were only set at Read and Exec and not Write. I put a tick in Write for both Group and World and now PHP works fine again.
I don't know at what point the permissions for tmp must have changed but for PHP to use them it must be set to have Write permissions.
Check that you're not running into diskspace issues. If all the permissions are correct (and 777 ought to do it for you), then you might still get this error (for some versions of PHP and Apache) if there isn't enough space to write to the disk.
If you have SSH access, here is how to correct the permission and ownership
Replace NAME_OF_USER by the user under which runs php. You can find it by simply putting these lines in a php file:
I have the same problem of permission, but on /var/lib/php/session/.
To fix it, I delete the file and restart php-fpm.
Now all works well.