prompting the user to signup using jquery?
i want to do something in jquery, if the user wants to vote on something, and they are not logged in or registered, you prompt them to do something just like stackoverflow, when the orange pop up thingy comes up, but i was wondering how you work with jquery and sessions!! i just want a push in the right direction! :))
Without knowing what your setup is (i.e. if you're using a framework, etc) it's hard to give the best possible answer; however, in general terms you'd just have to do the following:
- Check if the session is set and
Assuming the login session info is stored in a slot called 'username', you would do:
I recommend looking into jQuery UI for great ways to make things look more appealing.
If you want to use sessions, you can do something like this:
$_SESSION['logged_in'] would have to be set to either true or false. Then you just check that variable (userLoggedIn) every time the user wants to perform an action. Also check it on the server-side as I said above.
SO seems to use this method. If you look in the code, there is a line var isRegistered = true, which means that I am currently logged in.
Another way you could do it is to remove all voting functionality if they are not logged in, and add it when they are. This would save on load time for those who aren't logged in.
Sessions are managed on the server and have nothing to do with jQuery.
You can use jQuery to make nice modal dialogs for login screens, but that's just fancy HTML.