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(); ?>
Dharman
  • 30,962
  • 25
  • 85
  • 135
Basic Bridge
  • 1,881
  • 4
  • 25
  • 37
  • 5
    Looks like you don't have write rights for the /tmp directory at your site. Are you sharing the system with others? – Nobody moving away from SE Jul 25 '11 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`](http://php.net/manual/en/session.configuration.php#ini.session.save-path) – Wrikken Jul 25 '11 at 19:55
  • looks like you don't have permissions to read the file, what did ls -al say? – Drewdin Jul 25 '11 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 '11 at 19:55
  • @nobody well i'm not sharing system with any one.. and permission of temp folder is 755 thanks – Basic Bridge Jul 25 '11 at 19:56
  • For symfony2 session access folder have a look at: http://symfony.com/doc/current/cookbook/session/sessions_directory.html – shacharsol Aug 25 '15 at 14:36
  • 3
    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 07 '18 at 17:02

5 Answers5

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.

Peter Rowell
  • 17,605
  • 2
  • 49
  • 65
  • 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 '14 at 09:08
  • 3
    ini_set('session.save_path',getcwd(). '/'); session_start(); – Limitless isa Apr 30 '15 at 06: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 01 '16 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.

marcelog
  • 7,062
  • 1
  • 33
  • 46
6

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.

Phil
  • 10,948
  • 17
  • 69
  • 101
4

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

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).

Dor
  • 7,344
  • 4
  • 32
  • 45