flourishlib / flourish-classes

The class files for Flourish
http://flourishlib.com
182 stars 78 forks source link

Blank session created in database with each new pageview #177

Open superphonic opened 11 years ago

superphonic commented 11 years ago

Hi,

I seem to have an issue with my session set-up. I have fCache configured with a database backend, and then I have fSession configured with the fCache backend. Works a treat and logs in and out without issue. However...

Simply visiting the index of my site, not logged in, not required to be logged in, no checks etc... it only includes the init.php file, which then includes the config.php file - It create a blank session blob in my database. it contains

s:59:"fSession::type|s:6:"normal";fSession::expires|i:1358345285;";

The "expires" changes obviously.

It doesn't create any more blank sessions if I refresh the page, but if I restart my browser and visit the index page again, it will create another blank session in the database.

Now this wouldn't be such a big deal if it wasn't complicated by the fact that I am hosting my site on Amazons AWS cloud service. I have my App running on four EC2 instances (basically 4 self contained virtual Linux servers), when you visit my site you are directed to one of these via a load balancer.

This is the reason I am storing my sessions in the database, if I used the file system, the session would be created on one EC2 instance, and then the next page load might be from a different instance and the session file would not be there.

Anyway, Amazon have some sort of consistency check they run on the instances every 60 seconds, I cannot disable or change this. This is causing a blank session file to be created in the database each and every time the check happens.

I hadn't actually noticed this initially, but this morning I noticed that the table had over 100,000 blank sessions in it which is what made me investigate.

I have no idea where to start to debug this, but I am pretty sure there is nothing in my code that is causing it as I have tested with a vanilla script that just includes the init and config file from flourish - configured with the database backend, and it still happens.

I can provide code snippets etc if needed to help resolve the issue.

Thanks Alan

sandersid commented 11 years ago

I worked a short time with fSession. I think fSession is for "normal" use and normaly PHP clean up the old sessions. If you store the session on your way, you are responsible for cleaning up the session entrys. E.G. a Cronjob that remove expired entries...

superphonic commented 11 years ago

Not sure what you mean by "normal" use. I am using fSession to set the back to use a database via fSession::setBackend($session_cache); I am not doing anything out side of fSession.

Also this is only a problem on AWS. I push my App from a VPS development server to AWS via git, so the exact same App is running on my VPS using the database for sessions, and it works just fine. No garbage session creation.

superphonic commented 10 years ago

Believe it or not this is still an issue for me. Just bumping in case anyone strolls by who knows what's going on.