Ricardo,
   I've had some strange problems with session writing, but they always
returned back to the fact that "return false" was being used in the
session read function.  PHP 4.0.6 wouldn't write out sessions when
register_globals was set to off when you were using "return false".  PHP
4.1.0 crashes with signal 11 after a bit when using "return false".
I've filed a couple of bug reports with the request that this be fixed.
I believe a patch is either being worked on or already submitted, but
I'm not positive.

   Sean's problem is that he's using "return false" in his session read
function.  The session read function should return a blank value ('')
and not false when there's no data.  This was never clear in the
documentation (and complaint I made) but is quite true.  Once switching
over to using ('') instead of (false), I no longer had problems.

Jaime Bozza


-----Original Message-----
From: Junior, Ricardo [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 03, 2002 8:52 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Session troubles


Hi Sean !

I had the same problem... this can be resolved using the function
"session_write_close()" at the end of each script you use sessions. It
will force PHP to call the write and close function.

In some combinations of PHP version, Apache and OS, this problem doesn't
happens, but as you, I had this problem too.. :)

Put this function in yours PHP scripts and see if now them will work.

Here is an exemple of a test script:

<?php
    error_reporting( E_ALL );
    ini_set("session.save_handler","user");
    include( "./mysession.php" );       ----> where is my session
functions
declareted to use database...
    session_start();
?>
<html>
<head>
        <title>MySQL Session Management: Second Page</title>
</head>
<body>
<?php
    print( "SESSION User: $aUser<br>" );
    print( "SESSION Account: $aAccount<br>" );
    $aUser = "Katie";
    $aAccount = "2026";
    print( "CHANGED User: $aUser<br>" );
    print( "CHANGED Account: $aAccount<br>" );
    session_write_close();
?>
</body>
</html>

Cheers,
_________________________________
Ricardo J. A. Júnior, Software Engineer Trainee
Bowne Global Solutions

Phone   +55 21 2515 7713
[EMAIL PROTECTED]
www.bowneglobal.com.br

 -----Original Message-----
From:   Sean LeBlanc [mailto:[EMAIL PROTECTED]] 
Sent:   Wednesday, January 02, 2002 2:20 PM
To:     [EMAIL PROTECTED]
Subject:        Re: [PHP] Session troubles

On 01-02 07:45, Jaime Bozza wrote:
> I agree.  Perhaps make a feature request that disallows session
starting
> if save_handler=user and you haven't defined a session handler?
Then
> it could spit out a more correct error message.

Blast. I am still unable to get my own session handler to work. My
session handler's write never gets called; only my session_open and
session_read get called....the default file session handler still works,
if I change save_handler back to file instead of user.

As for the feature request, I guess I could - is there a mechanism to do
this outlined somewhere?


> -----Original Message-----
> From: Sean LeBlanc [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 01, 2002 8:32 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Session troubles
> 
> 
> On 12-31 09:23, Jaime Bozza wrote:
> > Sean,
> >   From your php error_log, it's saying the following:
> >     Failed to write session data (user)
> > 
> >   which sounds like it's having problems writing to the user-defined
> > session handler.  Are you using a user-defined session handler?  If 
> > not, make sure your php.ini file has:
> > 
> >     session.save_handler = files
> > 
> > And *NOT*:
> >     session.save_handler = user
> > 
> > That will make a big difference.
> 
> Good eye. That was it. I *did* have it as "user" because I was trying 
> to do my own user-defined session handler, and then stepped back and 
> was just trying to get the simpler case to work, w/o changing it back.
> 
> Thanks, it works now!
> 
> Now, I just need to see if I can get my session_handler working...
> 
> It's too bad the error message isn't more descriptive for this, BTW...
> 
> 
> > -----Original Message-----
> > From: Sean LeBlanc [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, December 29, 2001 1:21 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] Session troubles
> > 
> > 
> > On 12-29 12:56, David Jackson wrote:
> > > Sean --
> > > Don't know if this help but here's what I just worked for me. What

> > > ver. of PHP are you using? It seem to me that 3.x.x needs
> > > PHPLIB: http://sourceforge.net/projects/phplib
> > > to handle sessions?  -- David Jackson
> > > 
> > > --- sean.php -------
> > > <?php include("seaninc.php"); ?>
> > > 
> > > --- seaninc.php ------
> > > <?php
> > > session_start();
> > > session_register("i");
> > > $i++;
> > > echo $i;
> > > ?>
> > 
> > I'm using 4.0.6. I believe session handling was added as part of
> > standard 4.x, right (if configured to compile it)?
> > 
> > Some more info: I tried with Konqueror, as I know a cookie needs to 
> > be
> 
> > sent during the session_start() phase - I did get a dialog pop-up
> > asking if I wanted to accept the cookie, but I still got the error:
> > 
> > Fatal error: Failed to initialize session module in
> > /usr/local/apache/htdocs/sesstest.php on line 2
> > 
> > It says line 2 because I deleted some white space and commented out
> > code thas was before session_start().
> > 
> > I set logging errors on, and sent it to syslog. Here's what it says:
> > Dec 29 12:12:57 free httpd: PHP Fatal error:  Failed to initialize 
> > session module in /usr/local/apache/htdocs/sesstest.php on line 2
Dec 
> > 29 12:12:57 free httpd: PHP Warning:  Failed to write session data 
> > (user). Please verify that the current setting of session.save_path
is
> 
> > correct
> > (/tmp) in Unknown on line 0
> > 
> > But /tmp exists, and is world writeable:
> > 
> > free# ls -ld /tmp
> > drwxrwxrwt  16 root  wheel  1024 Dec 29 12:14 /tmp
> > 
> > > > On 12-29 09:59, Miles Thompson wrote:
> > > >> Sean,
> > > >> 
> > > >> What's going on in incl.php. Are you issuing a session_start()?
> > > > 
> > > > No, I was not.
> > > > 
> > > >> What if it's rearranged like so, as I understand you have to 
> > > >> register the session variable  before using it.
> > > >> 
> > > >> include("incl.php");
> > > >> session_start();
> > > >> session_register("mine");
> > > >> $mine++;
> > > >> echo $mine;
> > > > 
> > > > No dice, either. Actually, I had tried several permutations of 
> > > > the order  before posting. :)
> > > > 
> > > >> 
> > > >> There's the divide and conquer approach too.  What do you see 
> > > >> if you comment out the include, then issue a phpinfo() and a 
> > > >> die()?
> > > > 
> > > > Okay, I tried commenting out include, resulting in this code:
> > > > 
> > > > session_start();
> > > > session_register("i");
> > > > $i++;
> > > > echo $i;
> > > > 
> > > > When I run the above, I get this:
> > > > Fatal error: Failed to initialize session module in 
> > > > /usr/local/apache/htdocs/sesstest.php on line 6
> > > > 
> > > > Which is getting somewhere, in a way. Line 6 is session_start();
> > > > 
> > > > What part from phpinfo() output were you interested in? Or did 
> > > > you want to see all of it?
> > > > 
> > > > Thanks for the help.
> > > > 
> > > >> 
> > > >> HTH and Merry Christmas / Happy New Year - Miles Thompson
> > > >> 
> > > >> On Friday 28 December 2001 11:26 pm, Sean LeBlanc wrote:
> > > >> > I asked this on php-install list, but got no response so here

> > > >> > goes...
> > > >> >
> > > >> > I simply cannot get session to work correctly. Here's the 
> > > >> > test
> > > >> > script:
> > > >> >
> > > >> > include("incl.php");
> > > >> > session_start();
> > > >> > $mine++;
> > > >> > session_register("mine");
> > > >> > echo $mine;
> > > >> >
> > > >> > incl.php includes code to save/retrieve session information 
> > > >> > to/from DB.  It calles session_set_save_handler at the end.
> > > >> >
> > > >> > What happens is I get an error because it is trying to read 
> > > >> > the variable out and I get a DB error, but my session writing
> routine
> > 
> > > >> > is never called...I know, because I have a print in there. 
> > > >> > And
> > > >> > of
> > 
> > > >> > course, the var doesn't increment upon refreshes - it remains
> > > >> > 1.
> > > >> >
> > > >> > I've seen this before, and it was fixed, but I forget how it
> > > >> > was
> > > >> > done, as I didn't actually implement the solution (I hear and
I
> 
> > > >> > forget, I do and I remember, I guess). About my system:
> > > >> >
> > > >> > FreeBSD 4.4
> > > >> > Apache 1.3.20
> > > >> > PHP 4.0.6
> > > >> >
> > > >> > Any and all help appreciated.

-- 
Sean LeBlanc:[EMAIL PROTECTED] Yahoo:seanleblancathome 
ICQ:138565743 MSN:seanleblancathome AIM:sleblancathome 
Gravity really gets me down. 
(contributed by Frank v Waveren) 
Management QOTD:I think it is urgent that we run it up the flagpole and
mitigate risk on the proper sense of urgency.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to