How can I fix the Permission error when I call session_start()?

Solution 1:

Change session path where you can write data or contact server administrator about /tmp problem

http://php.net/manual/en/function.session-save-path.php

Solution 2:

you will need to change your session.save_path php.ini directive

You can do that using session_save_path

Solution 3:

If you have SSH access, here is how to correct the permission and ownership

sudo chown -R NAME_OF_USER /tmp

Replace NAME_OF_USER by the user under which runs php. You can find it by simply putting these lines in a php file:

$processUser = posix_getpwuid(posix_geteuid());
print $processUser['name'];
exit;

Solution 4:

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.

Solution 5:

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.