here is my solution, it might be totally wrong though:
i use mysql as database, it stores everthing i want, like player name. nick name,birthday, or something else.here is a pic of one of the database table, sorry i need hide something
[attachment=1:1mwwaqo9][/attachment:1mwwaqo9]
i use php to write my login and verification, if user login, use session to keep the login status.
set login redirect to your game url, so it acts like after login you can play.
now after loading the game, use ajax to read another php page, that page check the session, if user logged in already, it grab some information and echo as text message. if not logged in, user browser function to redirect to login page
some gloable variable to save those messages in your game
[attachment=0:1mwwaqo9][/attachment:1mwwaqo9]
tell me if you get better idea