Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2005, 06:38 AM
Registered User
 
Join Date: Jan 2005
Location: , , USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Professional PHP5 Ch. 15 Custom Session Handler

To begin, sorry if I posted this in the wrong place, but this seemed like the best place to do it.

I implemented the usersession.phpm (class definition for UserSession) found in ch 15 of Professional PHP5, but instead utilizing the PearDB database abstraction layer (also with a few minor changes) recommended in Ch 8. The code is nearly verbatim except for a few changes to sql statements and some added exception throwing for missing parameters. I'm getting a fatal error that I have no clue how to track down and debug when running the usersessiontest.php included with the book's code. The output is identical until the end, where this is added:

Fatal error: Call to private method UserSession::_session_write_method() from context '' in Unknown on line 0

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 running the app through Apache2 with PHP 5.0.3 installed. Everything seems to be peachy with the database handler abstraction class and the other classes I've tried. The class usersession.phpm is a custom session handler that reads and writes data and variables to a mysql database in my case.



// Remap PHP native session handling to use these class methods; found in the constructor for UserSession
session_set_save_handler(
    array($this, '_session_open_method'),
    array($this, '_session_close_method'),
    array($this, '_session_read_method'),
    array($this, '_session_write_method'),
    array($this, '_session_destroy_method'),
    array($this, '_session_gc_method')
);

// Overriding write method for UserSession class
private function _session_write_method($id, $sess_data) {
return TRUE;
}

Can anybody shed some light on how I might track this down? If there is more information required, let me know. Thanks for any help you can provide. Thank you ahead of time!
 
Old January 15th, 2005, 02:40 PM
Registered User
 
Join Date: Dec 2004
Location: , TX, .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the same problem. It was solved when I changed the custom session handler functions to 'public'. I know this is undesirable, but I believe it is the only way. Private methods cannot be accessed from outside the class, which is what the session does. I don't remember having the second problem (the 'warning' message). Fixing the first one might fix the second, though.

 
Old January 17th, 2005, 10:36 PM
Registered User
 
Join Date: Jan 2005
Location: Marietta, GA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sszabo
Default

Thanks. This solved my problem too. Was this code ever tested?
 
Old January 18th, 2005, 04:54 PM
Registered User
 
Join Date: Jan 2005
Location: Marietta, GA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sszabo
Default

BTW, I successully fixed and enhanced UserSession to work with Oracle 10g. Feel free to contact me if interested.
 
Old February 4th, 2005, 08:32 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ese error se debe a que tienes una conexion persistente abierta, tal vez en las funciones definidas en session_set_save_handler, este error se resuelve quitando la persistencia de las conexiones a tu base de datos.





Similar Threads
Thread Thread Starter Forum Replies Last Post
php5 chap 15 help needed twr Beginning PHP 1 January 5th, 2008 06:20 AM
Possible Errors in Professional PHP5 zimdawg79 Pro PHP 0 July 27th, 2006 06:39 AM
Pro PHP5, Ch.15, Class file usage BillD Pro PHP 0 April 7th, 2005 11:08 PM
Professional C# Second Edition Ch 15 Mike Smith BOOK: Professional C#, 2nd and 3rd Editions 0 January 5th, 2004 09:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.