ID:               19022
 Comment by:       oliver at veryhip dot com
 Reported By:      phpbugs at mx4k dot com
 Status:           No Feedback
 Bug Type:         Session related
 Operating System: linux (rh7.3), apache 1.3.26
 PHP Version:      4.2.2
 New Comment:

the sessions on my system sometimes look like this:

68.217.0.206.276341084854774671 

it's like the php isn't md5'ing the data or something to make the
session.  i would assume that maybe php is looking for file:
/tmp/sess_68.217.0.206.276341084854774671  instead of the
/tmp/sess_md5(68.217.0.206.276341084854774671 ) or base64 or whatever
php encodes the session to.  if i'm right about this, it wouldn't be
able to read the session because it's looking for another file cause
it's not encoding the session variable right... i get this in my apache
logs, which gets put in my sql database.  as i log the cookies in
apache logs, i had to reformat my sql tables to store 255 chars instead
of 32... i need to know how to fix this.  it happens randomly and i can
only wait till it screws up so i can try to fix it... please email me
if you find a fix!!!! thanks =]


Previous Comments:
------------------------------------------------------------------------

[2004-04-03 07:10:23] nicolas at swarm dot cc

Hi 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 :)

------------------------------------------------------------------------

[2004-04-02 12:01:59] phpbugs at chime dot tv dot cutthis

I'm losing session variables randomly too. Sometimes I get the "Failed
to write..." error but not always.

Since I don't host my servers I can't give full server details. However
here's a test script on both servers with the relevant PHPInfo:

Server A: http://chir.ag/test.php
Server B: https://secure.magictanorders.com/test.php

Test script:

<?php

  session_cache_expire(30);
  session_start();

  if($_SESSION["test"] == 1)
  {
    echo "<center>Sessions work.</center><br><br>";
  }
  else
  {
    $_SESSION["test"] = 1;
    echo "<center>Starting Session... Click refresh to see if the
session works or not.</center><br><br>";
  }

  phpinfo();

?>

Basically Server A works ALWAYS and remembers the session for upto 30
minutes. Server B randomly forgets the session in 1 second to 5
minutes. No session on Server B lasts more than 5 minutes.

The problem randomly started on Server B yesterday (Apr 1). We thought
it was output_buffering (and turned it ON) but that didn't help.
Problem was back this morning. The site was working perfectly for 3
weeks before breaking down randomly. If anyone can give any suggestions
I will be very thankful.

------------------------------------------------------------------------

[2004-03-26 16:40:43] guertin at brucemaudesign dot com

Ok .. i got my setup working again .. an old bug that I 
had forgotten the workaround for

I added (right before my initial session_start()):

session_destroy();

This destroys (presumably) any previous sessions 
leftover after an older login.  Maybe a php bug?  Maybe 
a browser issue?  Maybe a bit of both?  (I have it set 
to not use cookies but yet it still does).

Perplexing, but hopefully this helps out others that 
might run into this issue.

------------------------------------------------------------------------

[2004-03-26 16:15:52] guertin at brucemaudesign dot com

Experiencing the same problems here... out of the blue.  
Machine was running beautifully then all of a sudden it 
stopped.  No one can log in.  I changed nothing... there 
was not so much as a shell login on the machine for 30+ 
days.

sessions seem very fragile (as do many things in php 
lately, it's getting scarier to keep running in 
production environment).

[Fri Mar 26 16:14:04 2004] [error] PHP Warning:  Failed 
to write session data (files). Please verify that the 
current setting of session.save_path is correct (/
websites/sessions) in Unknown on line 0

I've done so far almost everything suggested that worked 
for others in here, none of it solved the problems.  I 
can tell you that:

1) it's NOT a permissions problem, my user running 
apache/php has full write access to /tmp
2) it's not required for this user to have a home 
directory.  For those that need to do this to 'fix' the 
problem, you OS is broken! (complain to your vendors)
3) it works for exactly one session.  The first login 
works fine and it seems that from there on in PHP tries 
to use the same session ID for everyone ?
4) manually deleting the existing session file allows on 
single login again after this.

Trying to track down more things. Really perplexing as 
to why/how it stopped working when it ran fine for a 8+ 
months.

------------------------------------------------------------------------

[2004-03-11 01:05:01] haccel at email dot com

After weeks of testing, I have fixed the problem at least for me.

The problem is the Zend Optimizer was corrupting/wiping (presumably)
the session data. Turning Zend Optimizer off completely fixed the
problem. When I turned Zend Optimizer back on and rebooted the session
problem was back again, this is the first reproducible action for me so
far.

Would be interesting to know how many others with this problem have
Zend Optimizer running.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/19022

-- 
Edit this bug report at http://bugs.php.net/?id=19022&edit=1

Reply via email to