We have a site that sits behind a load balancer. Behind the load balancer, we have 4 servers. They are identical in all ways. Separate from that, we have a database server.
We are using Propel and the sfGuardUser plugin. Symfony 1.0. The login is very strange and intermittent. If you log in, the next page might say you are logged out, the page after that might say you are again logged in, the page after that might say you are again logged out.
In fact, if you stay on the same page and hit refresh over and over, you might get:
I'm guessing this has something to do with cookies and the servers and the load balancer? If yes, how do we test?
If no, what other possibilities are there?
So, okay, this is almost certainly because session info is not being shared between the 4 servers. What is the most common way to get this working with Symfony?
I am looking here:
we have something like this:
db_table: SESSION_TABLE_NAME # Name of the table storing the sessions
database: DATABASE_CONNECTION # Name of the database connection to use
We are using a database like the one described here:
If we click the "Keep my logged in" button, then the login works, but otherwise it does not work.
We are using sfGuardUserPlugin for user management.
Any thoughts why the regular login (just using session data) does not work?
Florian Klein answers:
you may want to use a more scalable session Storage mecanism, like a database for example. Symfony comes with this kind of storage: you should be able to enable it from your app/config/factories.yml.
look at available options in the symfony doc, in the Reference book:
Lawrence Krubner comments:
On what page of the reference book? You should post an URL. The reason why I'm offering money as a prize is because I'm in a huge hurry.
Florian Klein comments:
Sorry for the inconvenience. here is a link to available storage options
So I repost the link pointing to the 1.0 documentation: http://www.symfony-project.org/api/1_0/storage
I think you should check this plugin :
sfCookieSessionStoragePlugin is a cookie-based session storage plugin for the symfony framework. Using this storage, the session data is directly stored in a cookie, only on the client side (no persistent session on the server side).
This removes the need for a shared session storage in a load-balanced platform, since a request from the user also carries the session data. As compared with other solutions for load-balanced session (database or memcache storage), cookie-based session storage is easier to install, and much faster.
Credits to the author : Francois Zaninotto
Lawrence Krubner comments:
Sadly, we are using Symfony 1.0
I've check the source and I don't see anything incompatible with symfony 1.0 you should download it and give it a try.
Don't you have an option on your load balancer called "sticky session" ?
This options assign one specific server to each new user connecting to your website, and each new request is always directed to that same server.
With that option you don't have to deal with session storage on memcached/key storage/mysql.
Other thing : since you are using database to store session take care to not enabling cache of query or result. That could explain your problem.