Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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!
Reply With Quote
  #2 (permalink)  
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.

Reply With Quote
  #3 (permalink)  
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?
Reply With Quote
  #4 (permalink)  
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.
Reply With Quote
  #5 (permalink)  
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.