# Custom PHP session handler (MS SQL) and register_shutdown_function()?]

- Thread: https://externals.io/message/3945
- Original archive: https://news-web.php.net/php.internals/3945
- Started by Tony Bibbs on 2003-08-14T17:48:53+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #3945 — Tony Bibbs — 2003-08-14T17:48:53+00:00

URL: https://externals.io/message/3945#3945

-------- Original Message --------
Subject: 	RE: Custom PHP session handler (MS SQL) and 
 `register_shutdown_function()`?
Date: 	Thu, 14 Aug 2003 17:12:41 +0100
From: 	James Cox
To: 	'Tony Bibbs'



The list is now internals@lists.php.net ...

> -----Original Message-----
> From: Tony Bibbs [mailto:tony@tonybibbs.com] 
> Sent: Thursday, August 14, 2003 3:32 PM
> To: php-dev@lists.php.net
> Subject: Custom PHP session handler (MS SQL) and 
> `register_shutdown_function()`?
> 
> 
> I just spend quite a few hours tracking down an issue that I 
> thought was 
> with my custom session handler (uses MS SQL Server 2000 via PEAR::DB) 
> but it turns out it was related to register_shutdown_function.
> 
> We have a simple script called db_init.php that has two functions, 
> doConnect() and doDisconnect(). We called 
> register_shutdown_function('doDisconnect') but apparrently this is 
> called before ending the user session which, as you might 
> guess, kills 
> my database connection and prevents my session write function from 
> working.  My hunch is that this is working as designed but I 
> wanted to 
> make sure.  If so, my next guess is you all will probably 
> recommend that 
> I call doDisconnect() from my session close method instead of using 
> register_shutdown_function, right?
> 
> Finally, in troubleshooting this, I learned that if your 
> connection dies 
> before you do the session write using MS SQL Server 2000, it kills an 
> apache child process and you get no response back.   Using the same 
> scenario with *MySQL* at least the mysql driver returns gracefully. I 
> know this is a bit obscure but, in my opinion the mssql driver should 
> work the same way (if possible) otherwise debugging is a real PITA.
> 
> I'm willing to provide sample code if needed.
> 
> --Tony
