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?
Your /tmp/ folder isn't writable. Make it writable.
chmod u+w /tmp/
You can test it with is_writable(session_save_path()).
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).
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
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.
Related
I am currently working on a user registration system for a client on GoDaddy hosting.
I have previously never had this sort of issue before on Hostgator and while testing locally on a PHP test server on OS X.
It's a fairly simple script too. common.php accesses the MySQL database, all of the pages (login, register, etc.) include common.php. Sessions start when the user logs in, etc.
I see the following errors at the top of the page:
Warning: session_start(): open(/home/content/10/12114910/tmp/sess_trmok9fgtb527mjp21a76shf54, O_RDWR) failed: No such file or directory (2) in /home/content/10/12114910/html/common.php on line 86
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/content/10/12114910/html/common.php:86) in /home/content/10/12114910/html/common.php on line 86
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/10/12114910/html/common.php:86) in /home/content/10/12114910/html/common.php on line 86
The following errors are at the bottom of the page.
Warning: Unknown: open(/home/content/10/12114910/tmp/sess_trmok9fgtb527mjp21a76shf54, O_RDWR) failed: No such file or directory (2) 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 () in Unknown on line 0
Once again, this is only a GoDaddy issue. My client was originally on Windows hosting and this just did not even work at all and I switched them to Linux hosting.
They were on PHP version 5.3 and I changed it to 5.4 and I have still had no luck.
I have never messed with a php.ini file. Would I need to create one? I have heard that uploading it into the public_html folder overrides the one on the server even though we are on a shared hosting plan.
Would I also need SSH access to create a tmp folder and set proper permissions for it?
This is usually quite easy to fix on crappy providers (I don't recommend GoDaddy, by the way).
Here is how I'd go about fixing it, hopefully it will help you.
Step 1: Make a directory and call it _sessions or something of that
nature.
Step 2: Give it a chmod of 775 so that the web server can write to it.
Step 3: On the first script that runs, right at the top place session_save_path("./_sessions");
Step 4 (optional, but recommended): Add either deny from all in a .htaccess file to prevent people from getting to the directory, or simply chmod 776.
Find out more about session_save_path() here: php.net/session_save_path
newb here, new to working with localhost in OS X.
I am running a MAMP stack on OS X. My session test file returns a series of warnings which I believe is due to the inability to write to the sessions folder which I have not been able to set to 0700.
I've checked for:
white space
file path http://localhost/sessions/
folder name (sessions)
I believe the problem is a permission issue. I am looking to be able to write to my localhost directory session folder. To do this I need to set the permission of the folder to 0700. I am hoping to find an solution that I can replicate with my limited level of expertise at this time.
This is the code:
<?php
ini_set('session.save_path','/htdocs/sessions');
session_start();
$_SESSION['test'] = "If you can read this, sessions are working!";
print $_SESSION['test'] . "<br>";
print "Session ID is: ". session_id()."<br>";
?>
These are the errors which only appear when i run local:
Warning: session_start(): open(/htdocs/sessions/sess_d1c5ef5a18bb844bfc667a0fc911191f, O_RDWR) failed: No such file or directory (2) in /Applications/MAMP/htdocs/review/itc240f/a_070-adminer/sessionTest.php on line 3
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /Applications/MAMP/htdocs/review/itc240f/a_070-adminer/sessionTest.php:3) in /Applications/MAMP/htdocs/review/itc240f/a_070-adminer/sessionTest.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Applications/MAMP/htdocs/review/itc240f/a_070-adminer/sessionTest.php:3) in /Applications/MAMP/htdocs/review/itc240f/a_070-adminer/sessionTest.php on line 3
If you can read this, sessions are working!
Session ID is: d1c5ef5a18bb844bfc667a0fc911191f
Warning: Unknown: open(/htdocs/sessions/sess_d1c5ef5a18bb844bfc667a0fc911191f, O_RDWR) failed: No such file or directory (2) 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 (/htdocs/sessions) in Unknown on line 0
/htdocs/sessions
does it exist? And, why would you choose to use a root directory in MacOSX? Perhaps you should map it to your user folder.
/Users/username/htdocs/session
I just upgraded my hosting plan, and now the user session isnt' working anymore. Users can't access the mebership area when they login, and here are the errors that are shown when opening my website:
Warning: session_start() [function.session-start]: open(/home/content/15/9277415/tmp/sess_enersdnbm88g5detjemgnptu47, O_RDWR) failed: No such file or directory (2) in /home/content/15/9277415/html/include/config.php on line 14
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/15/9277415/html/include/config.php:14) in /home/content/15/9277415/html/include/config.php on line 14
Warning: Unknown: open(/home/content/15/9277415/tmp/sess_enersdnbm88g5detjemgnptu47, O_RDWR) failed: No such file or directory (2) in Unknown on line
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
In config.php line 14 we have the session variables:
if(!session_id()) session_start();
if (!isset($_SESSION)) $_SESSION=array();
Does anybody have any idea why is this happening or how to fix it? These errors werent showing before the hosting plan upgrade.
Make sure that the directory /home/content/15/9277415/tmp exists and is writable by the webserver.
I have just moved over to a linux server on my shared hosting to see if it is less rubbish than a windows server on godaddy (I have been stupid enough to have paid them 12 months up front so I am stuck with those idiots now). I am now no longer able to use any kind of sessions at all.
They have got back to me saying that it is up to me to resolve the issue to get it to work... yes that is right... TO GET SESSIONS TO WORK! Excuse me if I seem a little irate but I am furious.
Can someone please inform me how I can in some way get sessions to work on an Apache server? I have never had to set this up before because it has never been a problem. As soon as I do:
<?php session_start() ?>
... it is just coming up with about 8 lines of errors saying that:
Warning: session_start() [function.session-start]: open(/var/chroot/home/content/30/10247530/tmp/sess_sgruthqkbhfms6ekcle2l0n6i5, O_RDWR) failed: No such file or directory (2) in /home/content/30/10247530/html/sessionthing.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/30/10247530/html/sessionthing.php:2) in /home/content/30/10247530/html/sessionthing.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/30/10247530/html/sessionthing.php:2) in /home/content/30/10247530/html/sessionthing.php on line 2
Warning: Unknown: open(/var/chroot/home/content/30/10247530/tmp/sess_sgruthqkbhfms6ekcle2l0n6i5, O_RDWR) failed: No such file or directory (2) 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 () in Unknown on line 0
I have tried creating a php.ini file and I still cannot get it to work properly. I have checked the settings using phpinfo() and I genuinely do not know where to go from here.
EDIT: There are a few things appearing down the side of the page now pointing to similar problems. For some reason I did not come up with those when I did a search. One of them is even closed: https://stackoverflow.com/questions/11374110/session-start-errors-on-godaddy-server?rq=1
That one says that they got it resolved with Godaddy so I think I will have to go back to them and tell them to sort it out. It is not that I do not want to learn how to configure the server... it is just that sessions should just work.
Make sure that there are no other <?php session_start() ?> declared, and try set your own session temp path,
<?php
if (!is_dir(session_save_path())) {
session_save_path ('your/custom/existing/directory');
}
session_start();
?>
PHP is trying to save the session in /var/chroot/home/content/30/10247530/tmp/, and it can't open that directory (either because it doesn't exist or because it doesn't have write permissions to it). Investigate PHP's access to this path and I believe that you'll get your sessions working - maybe you overlooked a config variable when you migrated your code to the new server?
I am trying to run this code in my server
<?php
session_start();
?>
I am getting following warning messages. I never saw such warning before .
Warning: session_start() [function.session-start]: open(/var/chroot/home/content/00/6684400/tmp/sess_uoouukt8m6efc0nc2ar5t2vq94, O_RDWR) failed: No such file or directory (2) in /home/content/00/6684400/html/html-tweetcomments/y.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/00/6684400/html/html-tweetcomments/y.php:2) in /home/content/00/6684400/html/html-tweetcomments/y.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/00/6684400/html/html-tweetcomments/y.php:2) in /home/content/00/6684400/html/html-tweetcomments/y.php on line 2
Warning: Unknown: open(/var/chroot/home/content/00/6684400/tmp/sess_uoouukt8m6efc0nc2ar5t2vq94, O_RDWR) failed: No such file or directory (2) 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 () in Unknown on line 0
how can i solve this problems?
Make sure, folder /var/chroot/home/content/00/6684400/tmp exists and is writable by PHP
sudo mkdir -p /var/chroot/home/content/00/6684400/tmp/
sudo chmod 1777 /var/chroot/home/content/00/6684400/tmp/
session_start() sets a cookie containing the session id. In the HTTP protocol, Cookies are sent in the HTTP header Set-Cookie.
If you send any output (including PHP warnings), this will be written into the HTTP answer body and PHP is no longer able to send a header.
To make sure the HTTP response body is written at the very end you can add a ob_start() at the very beginning of your PHP script.
This creates a output buffer which will be automatically flushed to output when the script reaches the end.
References
PHP Session
Sticky Bit
HTTP Cookies
PHP ob_start()
Problem with permissions.
Check tmp folder permissions. Make it writable.
Failed to write session data (files).
Also, check there's no HTML or whitespace before session_start()
Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at
/home/content/00/6684400/html/html-tweetcomments/y.php:2) in
/home/content/00/6684400/html/html-tweetcomments/y.php on line 2
Something is being printed before your session_start call. Check for any echo or even any blank space in html, before your call
The clue is the first error:
open(/var/chroot/home/content/00/6684400/tmp/sess_uoouukt8m6efc0nc2ar5t2vq94, O_RDWR)
failed: No such file or directory (2)
It looks like the directory that is being referenced for the session files either doesn't exist or isn't writable by the web user (user as which the web server is running).
Check that the directory exists - create it if not.
Ensure that it is group writable by the web server user.
The first error is causing the rest of the errors;
If there is same output before php code, move it after the php code
Example:
<script>
...javascript code...
</script>
<?php
session_start();
?>
move the script tag after the php tag. Like this:
<?php
session_start();
?>
<script>
...javascript code...
</script>