58

I'm getting the following error:

PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: open(/tmp/sess_49a20cbe1ef09a2d0262b3f7eb842e7b, O_RDWR) failed: Permission denied (13) in /home/------/public_html/includes/libs/ss.inc.php on line 1

The problem doesn't happen all the time, but comes and goes.

This the code at line on 1 in ss.inc.php

<?php session_start(); ?>
7
  • 5
    Looks like you don't have write rights for the /tmp directory at your site. Are you sharing the system with others? Jul 25, 2011 at 19:55
  • 1
    If I'd have a guess, I'd say the /tmp dir is sometimes full. You can alter the path where sessions are stored with session.save_path
    – Wrikken
    Jul 25, 2011 at 19:55
  • looks like you don't have permissions to read the file, what did ls -al say?
    – Drewdin
    Jul 25, 2011 at 19:55
  • What kind of a server are you using? It looks like your www user doesn't have permission to write /tmp which could be set up on purpose by your host if you have one. You might need to send your web host an email to get this resolved unless you can chmod yourself
    – Paul
    Jul 25, 2011 at 19:55
  • 2
    I solved it by just deleting the files as this "sess_e8vjrvit9duq61r9inj1iof285" from the /temp folder, so it creates a new session which has permission. This may have happened because you uninstalled and installed apache or something, at least with me that's how I solved it.
    – PerduGames
    Feb 7, 2018 at 17:02

5 Answers 5

85

You don't appear to have write permission to the /tmp directory on your server. This is a bit weird, but you can work around it. Before the call to session_start() put in a call to session_save_path() and give it the name of a directory writable by the server. Details are here.

3
  • 3
    Or PHP's session.save_path is not configured to /tmp. It may require changing session.save_path, e.g. session_save_path("/tmp");.
    – mahemoff
    Sep 17, 2014 at 9:08
  • 3
    ini_set('session.save_path',getcwd(). '/'); session_start(); Apr 30, 2015 at 6:41
  • 4
    My problem was similar, but it was the "session" path that had incorrect permission. (/var/lib/php/session on CentOS 6.6) I simply ran "sudo chown root:nginx session" and the error went away.
    – Drellgor
    Nov 1, 2016 at 18:33
16

Do a phpinfo(), and look for session.save_path. The directory there needs to have the correct permissions for the user and/or group that your webserver runs as.

5

I have had this issue before, you need more than the standard 755 or 644 permission to store the $_SESSION information. You need to be able to write to that file as that is how it remembers.

4

It seems that you don't have WRITE permission on /tmp.

Edit the configuration variable session.save_path with the function session_save_path() to 1 directory above public_html (so external users wouldn't access the info).

4

PHP does not have permission to write on /tmp directory. You need to use chmod command to open /tmp permissions.

Not the answer you're looking for? Browse other questions tagged or ask your own question.