After you have made a login to login, facebook will provide you with an authtoken that is unique, but it will expire someday. Based on this token, create a temporary "session_key" (it can be md5 (facebook_token + user_id), save this session_key in db and send it back to your application.
With each application request to your server, you must send this session_key and username. On the server side, you should check if session_key is in your database and if it is assigned "user_id".
If everything is in order, you can continue the action, otherwise return an error message.
When the user logs out, delete this session_key (it will be restored when he logs in using facebook).
Hope this helps.
source share