Login Form Tag
The Login Form Tag allows you to optionally place a login form in any template you choose, so that site members can log in.
Note: The member profile area has its own login form, which appears when someone who is not logged in tries to access a member's only area.
Here is an example showing how you might use the tag:
{exp:member:login_form return="site/index"}
<p><label>Username</label><br />
<input type="text" name="username" value="" maxlength="32" class="input" size="25" /></p>
<p><label>Password</label><br />
<input type="password" name="password" value="" maxlength="32" class="input" size="25" /></p>
{if auto_login}
<p><input class='checkbox' type='checkbox' name='auto_login' value='1' /> Auto-login on future visits</p>
{/if}
<p><input class='checkbox' type='checkbox' name='anon' value='1'
checked='checked' /> Show my name in the online users list</p>
<p><input type="submit" name="submit" value="Submit" /></p>
<p><a href="{path=''member/forgot_password''}">Forgot your password?</a></p>
{/exp:member:login_form}
Parameters
return=
return="site/index"
This parameter allows you to define where the user will be returned after successfully logging in. The parameter can be defined in two ways:
- Use the standard Template_Group/Template syntax to specify where to return the user. For instance, if you want the user to be returned to the "local" Template in the "news" Template Group, you would use: return="news/local"
- Use a full URL. For example: return="http://www.example.com/return.html"
Note that it is also possible to use this parameter on the login form under Admin > Member Profile Templates, as a parameter of the {form_declaration} variable:
{form_declaration return="site/index"}
name=
name="login_form"
This parameter allows you to specify a name attribute for the <form> tag:
Variables
{if auto_login}
{if auto_login} {/if}
It is recommended that you use this variable as indicated in the example code at the top. This conditional will display the contents inside (typically the "stay logged in" checkbox) based on how your session preference is set. In order for this feature to work you must be set to use "cookies only" and not sessions.
{if auto_login}
<p><input class='checkbox' type='checkbox' name='auto_login' value='1' /> Auto-login on future visits</p>
{/if}
Logging Out
You can easily create a logout link using the {path=LOGOUT} variable. For example:
<a href="{path=''LOGOUT''}">Log out</a>
User Contributed Notes
My other comment regards login pages. If you have a login form that is embedded on several pages, you can use the {segment} variables with the return="” parameter to dynamically build back the URL the user is on when they logged in to return them to that page.
If you want the user to return to where they were after directed to log in, just leave off the return parameter.
in response to this thread.
Additional Parameters available in EE 1.6.3 for the {exp:member:login_form} tag.
‘action’—if you want to change the form action.
‘id’ if you want to add an id="” attribute
‘onsubmit’ —if you want to change what happens when the form is submitted.
Source: core.functions.php Line 421
You must have an ExpressionEngine license and have attained a forum rank of "Lab Assistant" (100 posts) to contribute notes to the User Guide