Returning false is invalid for the session read function, and has caused
*MANY* issues with PHP and Sessions.  (Check the archives as well as the
bugs database.  I have a couple in there myself)

Change:
  return false;

To:
  return '';

And things should start working as expected.


Jaime Bozza


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


On 01-02 14:31, Jaime Bozza wrote:
> What do you have for the return values for your session_read function?

> (Specifically, what do you return when there's no data available?)

Well, it turns out that write *is* being called, but due to some feature
of session write, echo and print don't work, as I read on bugs.php.net.
So I put a file-writing mechanism in there and I see it is being called
and what was happening. I was trying to do an insert all the time, due
to bad logic, so it was cycling to 2, then stopping. Now it seems to
work properly. :)

As for the session read, I return false when no value is found.

> 
> Jaime Bozza
> 
> 
> -----Original Message-----
> From: Sean LeBlanc [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 02, 2002 11:20 AM
> 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]
> 
> 

-- 
Sean LeBlanc:[EMAIL PROTECTED] Yahoo:seanleblancathome 
ICQ:138565743 MSN:seanleblancathome AIM:sleblancathome 
Love is foolish... but I still might try it sometime. 
-Floyd, age 9 
Management QOTD:In order to make real progress we must improve
predictability and revise the expectations surrounding the minor
adjustments.


-- 
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