[eluser]Unknown[/eluser]
Greetings all,
What I am essentially trying to do is use ajax from jquery to check to see if a user is logged in or not. For my login session, I have the variable 'is_logged_in' set to TRUE once the user logs in.
I have a div with an id of 'login_form':
Code:
<div id="login_form">
<h1>Please login below</h1>
<?php
echo form_open('login/validate_credentials');
echo form_input('username', 'Username', 'id="username"');
echo form_password('password', 'Password', 'id="password"');
echo form_submit('submit', 'Login', 'id="login_button"');
echo anchor('login/signup', 'Create Account', 'id="create_account"');
echo form_close();
?>
</div>
and this is initially set to be hidden. What I would like to do is once '#login_menu' is clicked, check to see if the user is logged in. If they aren't logged in, I would like to display the "login_form" above (in jQuery
Code:
$('#login_form').addClass('active');
) else, do nothing.
So how can I use ajax in jQuery to request if the session variable 'is_logged_in' is false, then addClass 'active' ?
Thanks for your help!