Fix session security problem while login

This commit checks whether the session key has character other than
a-zA-Z0-9_ . If not, the key could be consider to safe.