NYCPHP Meetup

NYPHP.org

[nycphp-talk] When to close a mysql connection

Nate Abele nate at cakephp.org
Mon Jul 2 12:09:46 EDT 2007


> Cliff Hirsch wrote:
>>> Although I should know if I use database-based sessions, I am not  
>>> sure
>>> as I am not sure what exactly a database-based session is. So,  
>>> what is that?
>>
>> Standard PHP sessions are stored in flat files on the server. Not  
>> conducive
>> to scale-out as the session is local to a specific server, and  
>> there can be
>> security issues in a shared hosting environment. One alternative  
>> is to store
>> your sessionz in a database.
>>
>> See: http://us.php.net/manual/en/function.session-set-save- 
>> handler.php
>>
> Aha! So, if I'd have multiple servers and want to carry a session from
> one server to the next I could do so via a database assuming that the
> servers each have access to it. Now that's clever!
> Writing to each own's database will keep the session stuff  
> separated for
> shared hosting. Good to know.
>
> And again, NYPHP in persona of Cliff Hirsh made me a smarter person.
>
> Thanks!
>
> David

<shameless_plug>

Just FYI, CakePHP allows you to switch between flat-file and database  
driven sessions with a single configuration setting. ;-) It also  
allows you to drop in additional session storage engines.

</shameless_plug>


- Nate



More information about the talk mailing list