|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-10-15 07:03 UTC] golden at riscom dot com
Description:
------------
After migrating web server platform from win2000 to freebsd periodicly this message appears in logs:
PHP Fatal error: session_start(): Failed to initialize storage module. in index.php on line 5
PHP Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0
I'm using now FreeBSD 4.8 and Apache 2.0.47
On the line 5 in index.php just a call session_start();
here's part of my config in php.ini:
session.auto_start Off
session.bug_compat_42 On
session.bug_compat_warn On
session.cache_expire 180
session.cache_limiter nocache
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure Off
session.entropy_length 0
session.gc_divisor 100
session.gc_maxlifetime 1440
session.gc_probability 1
session.name PHPSESSID
session.save_handler files
session.save_path /tmp
session.serialize_handler php
session.use_cookies On
session.use_only_cookies Off
session.use_trans_sid On
Reproduce code:
---------------
<?php
session_start();
session_register("m");
Expected result:
----------------
not to see this message in logs, see the page expected
Actual result:
--------------
PHP Fatal error: session_start(): Failed to initialize storage module. in index.php on line 5
PHP Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0
and we get just a blank page instead of seeing of what actually expected
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 22:00:02 2025 UTC |
A client of mine is having the same problem. The script uses: session_start(); session_register('susername'); session_register('spassword'); session_register('sreferer'); session_register('susecode'); No destroy or anything special. If $username is set, than it sets the session $susername to $username. He tried accessing the page within a short time period after me, both passing the same username. However when I access it again it doesn't give me the error.Hi, I'm experiencing this problem in at least 2 sites. Since it's a error that appears in random, I wrote a simple script to try and reproduce the error. This is the script: <?php session_start(); header("Cache-control: private"); //IE 6 Fix if ( !isset($_SESSION['ctr']) ) { echo $_SESSION['ctr'] = 1; } else { echo $_SESSION['ctr']++; } ?> <meta http-equiv="refresh" content="10;url=test.php"> All it does is invoke "session_start()" and use one session variable. It then reloads itself every 10 seconds. On HOSTMANIL.ORG and HOSTMANIL.NET, the error comes up. But there is no pattern at all. Sometimes out of 20 refreshes, there's an error, half the time. If the error comes up, I have to do a manual refresh. I notice that the session variable is not destroyed at all. It continues counting from where it stopped. The problem is at one point in HOSTMANILA.ORG, it kept on coming up every 2 auto refreshes (and I do an F5). But now, it's was good for 45 straign auto refreshes before the error came up. That's how random the error is. I do a lot of programming, mostly in PHP but I'm not "deep" technical. So I'm not sure if I'm missing something. I'm running the scripts on 5 sites. These are all on different servers although all of them are from shared hosting services using cPanel / WHM. http://www.hostmanila.org/test.php http://www.hostmanila.biz/test.php http://www.hostmanila.net/test.php http://www.vcdpix.com/test.php http://www.smokedbangus.com/test.php So far, it's only happened on HOSTMANILA.ORG and HOSTMANILA.NET. Here's the rundown on each site: HOSTMANILA.ORG (error) Linux 2.4.30-gator_r1 Apache 1.3.33 (Unix) PERL 5.8.4 PHP 4.3.11 cPanel 9.9.9-STABLE 15 HOSTMANILA.BIZ (fine) Linux 2.4.30-1-s5 Apache 1.3.33 (Unix) PERL 5.8.3 PHP 4.3.11 cPanel 10.2.0-RELEASE 82 HOSTMANILA.NET (error) Linux 2.4.26-grsec Apache 1.3.33 (Unix) PERL 5.8.0 PHP 4.3.11 cPanel 10.0.0-RELEASE 7 VCDPIX.COM (fine) Linux 2.4.20-24.9 Apache 1.3.33 (Unix) PERL 5.8.1 PHP 4.3.9 cPanel 10.0.0-RELEASE 7 SMOKEDBANGUS.COM (fine) Linux 2.4.20-20.7smp Apache 1.3.33 (Unix) PERL 5.8.4 PHP 4.3.10 cPanel 10.0.0-CURRENT 107 I can't imagine developing anything in PHP without making use of session_start() so I hope the issue is resolved. Regards, Gul hostmanila.comI added the following line near the beginning of my PHP code: ini_set("session.save_handler", "files"); I have not seen the bug again after that, so far (clicked around like an idiot and everything worked fine). Which does not mean a lot, of course, due to the extremely random nature of that bug. Can anybody else confirm that this workaround works (or maybe not)? If it does "solve" the problem, the root cause may seem to be that PHP sometimes takes the wrong session handler (not the one which is defined in PHP.INI, which is "files" as well (while the error message seems to indicate "user"?)). Best regards, KlausI had the same problem, with the same error message, mainly on a dotclear "weblog" application, on the manage section. I put the PHP code given in the prepend file : ini_set("session.save_handler", "files"); and the error automagically disappear, for good (I hope!) The "save_handler" is just defined in php.ini with value "files", and not redefined anywhere else. It's strange that I have to define it again in the code. Best regards, gu!llaumeOn our ES 3 machines, we worked around this bug by pre-pending and appending the following code to all scripts executed (via the php.ini) file: [root@server root]# cat /tmp/auto_append_file.php <?php if (ini_get("session.save_handler") == "user") { @ini_set("session.save_handler","files"); @ini_set("session.save_path","/tmp"); @ini_set("session.use_cookies","1"); } ?> Since the error is never exhibited on a freshly spawned instance of apache, reducing the number of requests handled by apache (in Worker MPM mode) made sure that new children were spawned before old age increased probability of the bug; this seemed to be vital to make a 99% effective solution. [root@server root]# httpd -l Compiled in modules: core.c prefork.c http_core.c mod_so.c On our machine we also noticed that after testing this for workaround for 3 weeks we haven't used any swap on the machine as opposed to ~100MB previously, another desireable side effect.Hello We "solved" it by adding an auto_prepend file to every .php executed on our servers: [futurahost@mars lib]$ cat php.ini.prepend <? session_module_name("files"); ?> [futurahost@mars lib]$ grep auto_prepend_file php.ini auto_prepend_file = /usr/local/lib/php.ini.prepend [futurahost@mars lib]$ Anyway, we are very concerned about php developers completely ignoring this bug.This bug is easy to repeat in following way: 1) Set session_save_handler to user based like DB 2) Start page like normal, start session etc 3) CHANGE your session_id BEFORE you print anything to your screen 3.1) Destroy the old session_id 3.2) set new session id with session_id('your_id') 3.3) Try start_session() which will produce error message Problem is that system can not init custom session_save_handler in some odd reason. When changing session_handler to local files, anything goes normal. But with custom save handler like memcache or DB backend, code will fail. When you refresh page, problem disappears. I have tested this with Apache 2.2.8, PHP 5.2.5 and MySQL 5.1.23RC and with newest memcache. --JT--I have the same problem: "Fatal error: session_start(): Failed to initialize storage module: files (path: ) in...." and i've put this line: ini_set("session.save_handler", "files"); and nothing happens. i'm using IIS 6.0 and PHP 5.2.11