|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-08-21 11:09 UTC] phpbugs at mx4k dot com
hi there,
i have a webserver running rh7.3 with apache 1.3.26 and php4.2.1 as module. At random (not reproduceable reasons) all my session data gets lost. the session file exists but all data written there in previous scripts is gone.
All i get a hundreds of errors in my logfiles (like these):
[21-Aug-2002 16:47:07] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:47:13] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:48:29] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:48:51] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:49:49] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:50:04] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:50:19] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:52:02] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[21-Aug-2002 16:52:11] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
the webserver is at a very high load (70k users per day). problem is that i need that session data but i cannot rely on them.
the session info in php.ini looks like this:
[snip]
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
session.save_path = /tmp
; Whether to use cookies.
session.use_cookies = 1
; Name of the session (used as cookie name).
session.name = reqid
; Initialize session on request startup.
session.auto_start = 1
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 604800
; The path for which the cookie is valid.
session.cookie_path = /
; The domain for which the cookie is valid.
session.cookie_domain =
; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php
; Percentual probability that the 'garbage collection' process is started
; on every session initialization.
session.gc_probability = 1
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440
; Check HTTP Referer to invalidate externally stored URLs containing ids.
session.referer_check =
; How many bytes to read from the file.
session.entropy_length = 0
; Specified here to create the session id.
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
; Set to {nocache,private,public} to determine HTTP caching aspects.
session.cache_limiter = nocache
; Document expires after n minutes.
session.cache_expire = 180
; use transient sid support if enabled by compiling with --enable-trans-sid.
session.use_trans_sid = 0
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Patchestmp (last revision 2010-05-30 00:32 UTC by thanhdiavn at yahoo dot com dot vn)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
hi there, i have a webserver running rh7.3 with apache 1.3.26 and php4.2.1 as module. At random (not reproduceable reasons) all my session data gets lost. the session file exists but all data written there in previous scripts is gone. All i get a hundreds of errors in my logfiles (like these): [21-Aug-2002 16:47:07] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:47:13] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:48:29] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:48:51] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:49:49] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:50:04] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:50:19] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:52:02] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 [21-Aug-2002 16:52:11] PHP Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 the webserver is at a very high load (70k users per day). problem is that i need that session data but i cannot rely on them. the session info in php.ini looks like this: [snip] [Session] ; Handler used to store/retrieve data. session.save_handler = files ; Argument passed to save_handler. In the case of files, this is the path ; where data files are stored. Note: Windows users have to change this ; variable in order to use PHP's session functions. session.save_path = /tmp ; Whether to use cookies. session.use_cookies = 1 ; Name of the session (used as cookie name). session.name = reqid ; Initialize session on request startup. session.auto_start = 1 ; Lifetime in seconds of cookie or, if 0, until browser is restarted. session.cookie_lifetime = 604800 ; The path for which the cookie is valid. session.cookie_path = / ; The domain for which the cookie is valid. session.cookie_domain = ; Handler used to serialize data. php is the standard serializer of PHP. session.serialize_handler = php ; Percentual probability that the 'garbage collection' process is started ; on every session initialization. session.gc_probability = 1 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime = 1440 ; Check HTTP Referer to invalidate externally stored URLs containing ids. session.referer_check = ; How many bytes to read from the file. session.entropy_length = 0 ; Specified here to create the session id. session.entropy_file = ;session.entropy_length = 16 ;session.entropy_file = /dev/urandom ; Set to {nocache,private,public} to determine HTTP caching aspects. session.cache_limiter = nocache ; Document expires after n minutes. session.cache_expire = 180 ; use transient sid support if enabled by compiling with --enable-trans-sid. session.use_trans_sid = 0 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"hi there, as far as i can tell the problem only appears if the server runs on middle to high load. (eg. >100httpd) the problem machine is a p4-1,8ghz with 1gig ram (no smp) and we couldnt yet reproduce the problem on any other server. the machine only runs the httpd, postgres is running on a different machine. its using a IDE hd (some special scsi or something) i'm willing to apply some patches to get rid of the problem. i looked into the problem myself but couldn't find any problem in PS(mod)->write or the resulting write to the hd (which i guess is PS_WRITE_FUNC(files)). I never coded on linux neither much of c (only c++, c#, java) but maybe p/write does have a problem. #ifdef HAVE_PWRITE n = pwrite(data->fd, val, vallen, 0); #else lseek(data->fd, 0, SEEK_SET); n = write(data->fd, val, vallen); #endif anyways, send me some patches via email and i'll try my best to find a workarround. greets, thomasHello, I am also experiencing this bug. I am using Debian, 2.4.18 kernel, SMP machine, PHP 4.2.3. (also observed bug on PHP 4.1.2). The server is not experiencing a heavy load. I am attempting to script a temporary fix for this bug until there is a permanent fix in a stable PHP release. Would something like the following work? 1. At the end of every page request, backup the session file: copy(session_save_path() . '/sess_' . session_id(), session_save_path() . '/sess_' . session_id() . '_bak'); 2. At the top of each script that requires session data, check to see if the main session file has been truncated. If so, replace it with the backup that you have created. Assuming you have the session Id stored in a cookie as 'user_sess_id': if (isset($_COOKIE[user_sess_id]) && file_exists(session_save_path() . '/sess_' . $_COOKIE[user_sess_id] . '_bak') && file_exists(session_save_path() . '/sess_' . $_COOKIE[user_sess_id]) && (filesize(session_save_path() . '/sess_' . $_COOKIE[user_sess_id]) == 0) && (filesize(session_save_path() . '/sess_' . $_COOKIE[user_sess_id] . '_bak') > 0) ) { // restore the session file copy(session_save_path() . '/sess_' . $_COOKIE[user_sess_id] . '_bak', session_save_path() . '/sess_' . $_COOKIE[user_sess_id]); } // continue with script... Does this have any hope of helping restore the lost session data? Or would PHP have already read in the session data from the file on disk before it reaches this point of processing the code? Any advice on how PHP coders can write a temporary fix for this bug would be greatly appreciated. Thanks, Taylor DavisAnother data point. I've recently moved a system from a hosted server running 4.06 to a server under my control running redhat 7.3 and php 4.2.3 Since the move I've been getting very occasional cases of users logging in and receiving someone else's session. The session handling is very simple. On login session_name($db_name); session_start(); $user = new User($userid, $passwd); session_register("user"); On return session_name($db_name); session_start(); I've tried various workarounds like session.entropy_length = 512 session.entropy_file = /dev/urandom in the belief that somehow the two people were getting the same ID and hence temp file But all this was just thrashing at the problem. Then I checked my own cookies and discovered the same as ivo@ibuildings.nl The cookie contained two session IDs. So I deleted all relevant cookies. Logged out and in and now I'm back to the expected single ID in the cookie. I have logging turned on but have not yet seen any errors.Okay, I think I solved this bug for me at least. I would receive this error: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (c:\windows\temp) in Unknown on line 0 and I finally tracked it down to being I was sometimes setting the session_id(""); to blank, aka, to nothing. That would cause it to fail. I still think this is a bug, because you shouldn't be able to break it by setting it to nothing. The reason I was unable to track this down quicker was because I had no idea I was passing a blank variable to the session_id. So I looked into that, and it turns out PHP fails to delete cookies. I think their is a bug with the delete cookie functions...you might want to check into that. To solve this, instead of deleting the cookies, I just set them to -1, and then checked if they were -1, and if so, treated them as if they weren't there. I hope this helps, NateI was having similar problems. It seems to be related to the require() statement. I solved this putting the seesion_start() statement outside the included script (e.g. if I have require("auth.php") I put session_start() issue outside auth.php. At least It works in my particular case. You can test it and see if it works for you too. Please post your results. IFor the people not experiencing the "failed to write session data" error but those of you that do experience the 'random lose of session data' here a possible solution: Check if your script uses cookies AND sessions in one script. Comment all the 'setcookie' lines and all other cookie functions in your script and check if your problem still exists... It solved the problem ("dissapearing sessions causing users to log out") for me.hello palls, i hope my workaround might help. i have experienced the same failure on a debian woody dev server with no load running a pentium 100 mhz with php 4.1.2. i had the problem on a page which was calling session_id() with no parameters. after reading this list, i have changed the first call to session_id() to: session_id(session_id("a")) and the problem dissapeared. i must mention that after the first time i found the problem, it didn't stop until this workaround. although i didn't examine php source, it might be that the solution for this case would be checking the number of parameters to session_id(). thank you very much for your work and contributions. alexHi guys, i experienced the same problem since 3 weeks.. my session dies after the current request... after some investigations: php sends a wrong "Set-Cookie" header in the HTTP request.. maybe due to the load.. i'm not sure ================================================== GET / HTTP/1.0 Accept: */* Referer: my_host Accept-Language: fr-ch User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Host: my_host Connection: Keep-Alive HTTP/1.1 200 OK Date: Sat, 03 Apr 2004 11:23:42 GMT Server: Apache X-Powered-By: PHP/4.3.3 Set-Cookie: PHPSESSID=50f49658391ab2bfd84ab11baf7b124c; expires=Tue, 23-Sep-1902 09:55:18 GMT; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html ================================================== as you can see, the date is wrong .. i made my test today (4th April) .. mmmh.. i wasn't born when the cookie died :) i made a very straightforward workaround that is to backup the session id and restore it as needed.. you can simply cut & paste the following code <? // restore the backup cookie if (isset($_COOKIE["PHPSESSIDBK"])) { $_COOKIE["PHPSESSID"] = $_COOKIE["PHPSESSIDBK"]; } // start the session as usual session_start(); // create the backup if needed if (!isset($_COOKIE["PHPSESSIDBK"])) { header("Set-Cookie: PHPSESSIDBK=".session_id()); // you can add the expiry date if you want } ?> i tried this and it works fine.. there's maybe some smarter to do.. but that way it works.. i hope it will also help the php team to find out what happens... the only reason i can see is server-load.. on my dev server it never happened.. so .. let's go back to work :)