Page 1 of 1

Session storage and FTP wrappers

Posted: Thu Feb 28, 2008 10:09 pm
by alex.barylski
I'm curious, assume you had a web application spread across several remote servers, how does one centralize the session storage so the PHP script on server A knows to lookup sessions stored on server Z. Likewise server B should lookup sessions on server Z as well.

I see two possible solutions:

1) Override the default storage mechianisms (session_set_save_handler) and store the data on the remote server - PITA
2) Possibly set the storage path with an ftp:// wrapper - much easier :D

Has anyone ever tried the latter - is there a way to configure PHP so that it allows ftp:// wrappers inside it's own INI file???

Cheers :)

Re: Session storage and FTP wrappers

Posted: Thu Feb 28, 2008 10:13 pm
by hawkenterprises
No that is actually a built in security *feature*. You can't spread sessions across domain names to help prevent session hijacking. I'm sure there is a package hack but I would recommend just creating your own session system it's actually fairly easy to do.

Just use the same idea as the file save handle, just write a routine to load and save a file on a central server. That file contains all your session information. Thus you just created a central session system without using PHP's built-in ones.

Re: Session storage and FTP wrappers

Posted: Fri Feb 29, 2008 12:59 am
by Kieran Huggins
I think Hockey's looking for more of a load-balancing type of setup, not cross-domain sessions.

Either way, FTP would kill your performance. Just watch the activity log in an FTP program sometime, it's sloooooow. Can you imagine reading and writing to that on every request? Ugh.

The answer? Use DB session storage: http://www.devshed.com/c/a/PHP/Storing- ... a-Database

Fast, cross-platform, and easy to set up! If the article doesn't already advocate this (it was the first result on Google, it might be total crap) I'd recommend using a HEAP table for sessions. HEAP (or sometimes called MEMORY) tables are kept in memory, and thus will perform better whilst not killing the rest of your DB server.

Re: Session storage and FTP wrappers

Posted: Fri Feb 29, 2008 3:15 am
by alex.barylski
Ick...I was afraid I would have to go with the 'more work' option. :P

Ah well...figured I'd ask just incase.