Re: [PHP] Saving session to database

2013-05-17 Thread Matijn Woudt
On Thu, May 16, 2013 at 2:49 PM, Lester Caine les...@lsces.co.uk wrote:

 Matijn Woudt wrote:




 On Thu, May 16, 2013 at 10:43 AM, Lester Caine les...@lsces.co.uk
 mailto:les...@lsces.co.uk wrote:

 I'm having a problem with webtrees ... http://webtrees.net/
 My copy is running on http://webtrees.lsces.org.uk and you will see
 that it
 is throwing an error relating to the session handling.

 Running Apache 2.2.22, PHP5.4.14, MySQL 5.5.31 (
 http://lsces.org.uk/phpinfo.__**phphttp://lsces.org.uk/phpinfo.__php
 http://lsces.org.uk/phpinfo.**php http://lsces.org.uk/phpinfo.php )


 If I comment out the session_set_save_handler() section of
 session.php then
 I can log in and use the site. Have tried reworking that as a
 SessionHandlerInterface without any success. As far as I can see, the
 'write' function of the handler is not being called and while there
 are
 various notes about problems with PHP5.4 blocking access to the write
 and
 close functions, none of the fixes I have tried have resulted in a
 working
 setup.

 Anybody seen this problem with PHP5.4?

 http://lsces.org.uk/hg/__**webtrees/file/dcf6ff358108/__**
 includes/session.php#l334http://lsces.org.uk/hg/__webtrees/file/dcf6ff358108/__includes/session.php#l334

 http://lsces.org.uk/hg/**webtrees/file/dcf6ff358108/**
 includes/session.php#l334http://lsces.org.uk/hg/webtrees/file/dcf6ff358108/includes/session.php#l334
 is
 the code that seems to be failing.


 What error do you get? I tried loading the site but it shows up fine.
 In general, you should post the error message in your email anyway, for
 two reasons:
 1) Most people on this list don't bother to open a (terrible slow)
 website.
 2) Archives, so if anyone after you comes up with the same problem, he
 will be
 able to refer to the archives to find his solution.


 Been working on this most of the morning without success :(
 Faulty version is back up, and showing all the error messages, but
 basically ...

 ERROR 2: session_regenerate_id(): Session object destruction failed
 0 Error occurred on in function session_regenerate_id
 But I think it's the initial session write that is failing

 ERROR 2: session_write_close(): Failed to write session data (user).
 Please verify that the current setting of session.save_path is correct
 (/var/lib/php5)
 0 Error occurred on in function session_write_close

 But it should be writing to the database not the file directory.



It seems to me the session functions are failing, probably due to problems
with the database. Have you checked that there actually is a ##session
table in your database?
You might want to add some debugging code to these functions, to check if
errors occur with inserting or retrieving the sessions from the database.

- Matijn


Re: [PHP] Saving session to database

2013-05-17 Thread Lester Caine

Matijn Woudt wrote:


It seems to me the session functions are failing, probably due to problems with
the database. Have you checked that there actually is a ##session table in your
database?
You might want to add some debugging code to these functions, to check if errors
occur with inserting or retrieving the sessions from the database.


Well past that stage without making any progress.
Using the write function outside of the session_set_save_handler() it works 
perfectly, and then the read can see the saved sessions and can load them.


I am convinced that something is wrong with the general setup which is 
preventing the write and close from firing when it should. I can not trace any 
attempt to call the write function in the session handling.


I'm currently checking out the adodb-session handler which WAS working in PHP5.3 
but seems to be showing similar problems in PHP5.4


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Saving session to database

2013-05-17 Thread Matijn Woudt
On Fri, May 17, 2013 at 8:07 PM, Lester Caine les...@lsces.co.uk wrote:

 Matijn Woudt wrote:


 It seems to me the session functions are failing, probably due to
 problems with
 the database. Have you checked that there actually is a ##session table
 in your
 database?
 You might want to add some debugging code to these functions, to check if
 errors
 occur with inserting or retrieving the sessions from the database.


 Well past that stage without making any progress.
 Using the write function outside of the session_set_save_handler() it
 works perfectly, and then the read can see the saved sessions and can load
 them.

 I am convinced that something is wrong with the general setup which is
 preventing the write and close from firing when it should. I can not trace
 any attempt to call the write function in the session handling.

 I'm currently checking out the adodb-session handler which WAS working in
 PHP5.3 but seems to be showing similar problems in PHP5.4


Well, I'm not sure what would be the problem here, but some general
comments:
There have been various changes in session handling between 5.3 and 5.4, so
most likely it is in there. Check if there are any references to
register_shutdown_function, and replace them with session_register_shutdown.
Second, check the return value of session_set_save_handler, it is a bad
habit not checking return value of a function, just because it works.
If that doesn't help, take the session piece out of the big framework, and
test it in a separate file. If that also fails, you've got a small piece of
code you can post here which will encourage others to have a look at it at
their box.

- Matijn


Re: [PHP] Saving session to database

2013-05-17 Thread Andrew Ballard
I've found database session storage requires extra diligence in error
handling. When I see that error at 0 it is usually because something blew
up either before the session handler was ready or after it was torn down.

Andrew
On May 17, 2013 2:42 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Fri, May 17, 2013 at 8:07 PM, Lester Caine les...@lsces.co.uk wrote:

  Matijn Woudt wrote:
 
 
  It seems to me the session functions are failing, probably due to
  problems with
  the database. Have you checked that there actually is a ##session table
  in your
  database?
  You might want to add some debugging code to these functions, to check
 if
  errors
  occur with inserting or retrieving the sessions from the database.
 
 
  Well past that stage without making any progress.
  Using the write function outside of the session_set_save_handler() it
  works perfectly, and then the read can see the saved sessions and can
 load
  them.
 
  I am convinced that something is wrong with the general setup which is
  preventing the write and close from firing when it should. I can not
 trace
  any attempt to call the write function in the session handling.
 
  I'm currently checking out the adodb-session handler which WAS working in
  PHP5.3 but seems to be showing similar problems in PHP5.4
 
 
 Well, I'm not sure what would be the problem here, but some general
 comments:
 There have been various changes in session handling between 5.3 and 5.4, so
 most likely it is in there. Check if there are any references to
 register_shutdown_function, and replace them with
 session_register_shutdown.
 Second, check the return value of session_set_save_handler, it is a bad
 habit not checking return value of a function, just because it works.
 If that doesn't help, take the session piece out of the big framework, and
 test it in a separate file. If that also fails, you've got a small piece of
 code you can post here which will encourage others to have a look at it at
 their box.

 - Matijn



Re: [PHP] Saving session to database

2013-05-17 Thread Lester Caine

Andrew Ballard wrote:

I've found database session storage requires extra diligence in error handling.
When I see that error at 0 it is usually because something blew up either before
the session handler was ready or after it was torn down.


Found the culprit ...
Suhosin
http://www.simplemachines.org/community/index.php?topic=486606.0 gives the 
pointer but I've not followed through on an updated version. This is a stock 
SUSE install and I don't want to manually 'fix' it so I've just disabled Suhosin.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Saving session to database

2013-05-16 Thread Matijn Woudt
On Thu, May 16, 2013 at 10:43 AM, Lester Caine les...@lsces.co.uk wrote:

 I'm having a problem with webtrees ... http://webtrees.net/
 My copy is running on http://webtrees.lsces.org.uk and you will see that
 it is throwing an error relating to the session handling.

 Running Apache 2.2.22, PHP5.4.14, MySQL 5.5.31 (
 http://lsces.org.uk/phpinfo.**php http://lsces.org.uk/phpinfo.php )

 If I comment out the session_set_save_handler() section of session.php
 then I can log in and use the site. Have tried reworking that as a
 SessionHandlerInterface without any success. As far as I can see, the
 'write' function of the handler is not being called and while there are
 various notes about problems with PHP5.4 blocking access to the write and
 close functions, none of the fixes I have tried have resulted in a working
 setup.

 Anybody seen this problem with PHP5.4?

 http://lsces.org.uk/hg/**webtrees/file/dcf6ff358108/**
 includes/session.php#l334http://lsces.org.uk/hg/webtrees/file/dcf6ff358108/includes/session.php#l334is
  the code that seems to be failing.


What error do you get? I tried loading the site but it shows up fine.
In general, you should post the error message in your email anyway, for two
reasons:
1) Most people on this list don't bother to open a (terrible slow) website.
2) Archives, so if anyone after you comes up with the same problem, he will
be able to refer to the archives to find his solution.

- Matijn


Re: [PHP] Saving session to database

2013-05-16 Thread Lester Caine

Matijn Woudt wrote:




On Thu, May 16, 2013 at 10:43 AM, Lester Caine les...@lsces.co.uk
mailto:les...@lsces.co.uk wrote:

I'm having a problem with webtrees ... http://webtrees.net/
My copy is running on http://webtrees.lsces.org.uk and you will see that it
is throwing an error relating to the session handling.

Running Apache 2.2.22, PHP5.4.14, MySQL 5.5.31 (
http://lsces.org.uk/phpinfo.__php http://lsces.org.uk/phpinfo.php )

If I comment out the session_set_save_handler() section of session.php then
I can log in and use the site. Have tried reworking that as a
SessionHandlerInterface without any success. As far as I can see, the
'write' function of the handler is not being called and while there are
various notes about problems with PHP5.4 blocking access to the write and
close functions, none of the fixes I have tried have resulted in a working
setup.

Anybody seen this problem with PHP5.4?


http://lsces.org.uk/hg/__webtrees/file/dcf6ff358108/__includes/session.php#l334

http://lsces.org.uk/hg/webtrees/file/dcf6ff358108/includes/session.php#l334 is
the code that seems to be failing.


What error do you get? I tried loading the site but it shows up fine.
In general, you should post the error message in your email anyway, for two 
reasons:
1) Most people on this list don't bother to open a (terrible slow) website.
2) Archives, so if anyone after you comes up with the same problem, he will be
able to refer to the archives to find his solution.


Been working on this most of the morning without success :(
Faulty version is back up, and showing all the error messages, but basically ...

ERROR 2: session_regenerate_id(): Session object destruction failed
0 Error occurred on in function session_regenerate_id
But I think it's the initial session write that is failing

ERROR 2: session_write_close(): Failed to write session data (user). Please 
verify that the current setting of session.save_path is correct (/var/lib/php5)

0 Error occurred on in function session_write_close

But it should be writing to the database not the file directory.

--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php