0

I get a session error which I did not have before which is strange.

Warning: session_start() [function.session-start]: open(/tmp/sess_6768c4a8b1cff40d24a3a87de701c865, O_RDWR) failed: Read-only file system (30) in /home/public_html/ctcms/index.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/public_html/ctcms/index.php:4) in /home/public_html/ctcms/index.php on line 4

 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/public_html/ctcms/index.php:4) in /home/adrian/public_html/ctcms/index.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/ctcms/index.php:4) in /home/public_html/ctcms/library/CT/Controller.php on line 40

Warning: Unknown: open(/tmp/sess_6768c4a8b1cff40d24a3a87de701c865, O_RDWR) failed: Read-only file system (30) 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`

I have only session_start(); in my index.php at line 4. How can I fix this?

Mythriel
  • 1,360
  • 5
  • 24
  • 45
  • 1
    PHP is telling you that it cannot open the file that backs your session variable across requests for reading and writing, so you should start looking for why this happens. – Jon Mar 06 '12 at 07:51
  • possible duplicate of [PHP session handling errors](http://stackoverflow.com/questions/5104065/php-session-handling-errors) – Esailija Jun 15 '12 at 08:24

4 Answers4

4

Your /tmp/ folder isn't writable. Make it writable.

chmod u+w /tmp/

You can test it with is_writable(session_save_path()).

alex
  • 479,566
  • 201
  • 878
  • 984
3

Warning: session_start() [function.session-start]: open(/tmp/sess_6768c4a8b1cff40d24a3a87de701c865, O_RDWR) failed: Read-only file system (30) in /home/public_html/ctcms/index.php on line 4

It looks like /tmp is on a read-only file system. This is not normal. Tell your sysadmin/hosting provider to have a look at it; the machine may have a serious problem.

If the machine is yours, check the logs for any errors related to the file system and try to remount the disk in read-write (mount -o remount,rw /dev/yourdevicehere).

Joni
  • 108,737
  • 14
  • 143
  • 193
1

Yuo can't write on /tmp/

Make it writable and redo the operation.

Moreover, remember that session_start() have to be the first operation that you do on the page. Take a look: php manual

DonCallisto
  • 29,419
  • 9
  • 72
  • 100
0

This was a known bug in version(s) of PHP . Depending on your server environment, you can try setting the sessions folder to 777:

/var/lib/php/session (your location may vary)

I ended up using this workaround:

session_save_path('/path/not/accessable_to_world/sessions');
ini_set('session.gc_probability', 1);

You will have to create this folder and make it writeable. I havent messed around with the permissions much, but 777 worked for me (obviously).

Make sure the place where you are storing your sessions isn't accessible to the world.

This solution may not work for everyone, but I hope it helps some people!

please select an answer and mark accordingly.

roberthuttinger
  • 1,172
  • 1
  • 17
  • 31
  • Would this bug produce the error message `Read-only file system` when the file system is in fact mounted read-write? Or is the bug that sessions are saved somewhere other than configured? – Joni Jun 15 '12 at 06:20
  • from the original question it looks as if there are several things going on. however if the the drive is mounted read only you will see a lot of evidence of this before you arrive at the session error. To that end, I answered only the session issue, which I was able to solve by moving the session save folder for this instance. – roberthuttinger Jun 15 '12 at 15:54