I’m working a Symfony 1.4 apps, and I need to prevent a user beeing able to login more than once into the application, I mean if S/He is already logged in, it should not be able to logged in just opening a new browser.
- user log in on Chrome.
- Open Firefox, try to login and then can’t login because a session is already active on Chrome
I want to avoid same user begins another session with a different browser in the same computer, or in another.
The only solution I think about is to use session in MySQL (or your database) and then, check if a session is active for a given user so it can login or not.
It won’t be an easy part. I did that one time but can’t find the source code.. So I will describe what you will have to do.
sfPDOSessionStorageto store session in db (you can follow this blogpost)then create a custom storage that extend
sfPDOSessionStorageto be able to add more field into the session table.You will have a new field (for example
sess_user_id) inside yourfactories.yml, something like this :You will need to update method
sessionRead&sessionWritefrom your custom session storage to: