I'm trying to create a Login / Register pop up div mechanism that could be triggered a) by pressing the register / login buttons on the top right corner of the web application b) after the user fill a form, he is asked to sign in or register (after which his input are saved)
I'm having trouble understanding how to include the login process within the submit form process, knowing the following:
1) The login /register pop up div is handled by jquery. The Form is at the bottom of my page template and could be displayed on every page of the website.
I suppose that when the user complete his submission (say a review 开发者_StackOverflow中文版like on Yelp.com), it triggers the login / register jquery to display the pop up div.
But how does the review submission catch the process back to verify that the user is now indeed logged in / registered and it's ok to insert data in DB.
Am I going on the wrong track? Any other options?
Firstly you should know that the login / is logged in data is stored in the session on the server.
So when you present the page to the user, you already know on the server side that it is logged in or not.
If the user is logged in, you shouldn't load the login div anyway.
If the user is not logged in, then, if he wants to do an action that requires him to be logged in, you present him the login div. If he completes the login/register form, you have two options:
- do the login in an AJAX manner
- do the login the standard way
精彩评论