Image Caption

Thursday, February 7, 2013

Logout link for Joomla 1.5, 2.5 and 3.0

[Note: Tested in Joomla 1.5, 2.5, 3.1.5]

Joomla 1.5 Logout Link

<?php
$returnURL = base64_encode(JURI::root() . "");
$user =& JFactory::getUser();
echo 'Hi,'.$user->username;
?>
<a href="index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>">
<input  type="button" name="Submit" class="button" value="Logout"></a>

Joomla 2.5 Logout Link


<a href="index.php?option=com_users&task=user.logout&<?php echo JUtility::getToken(); ?>=1">
<input  type="button" name="Submit" class="button" value="Logout">
</a>


Joomla 3.1 Logout Link

//JUtility::getToken() has been removed in Joomla 3.0. Use JSession::getFormToken() instead.

<a href="index.php?option=com_users&task=user.logout&<?php echo JSession::getFormToken(); ?>=1">
<input  type="button" name="Submit" class="button" value="Logout">
</a>


12 comments:

Rajat Tripathi said...

yes, its working...thanks :)

Anonymous said...

thanks for that, but on Joomla 3.0 I get the error:


Fatal error: Call to undefined method JUtility::getToken() in...

Unknown said...

Joomla 3.1 this error will occur,thanks guys

Ricky said...

It worked.. Thanks

Anonymous said...

Thanks. Very helpful.

Anonymous said...

Thanks for the links, but how can we created loging | logout option on header are with above link on 2.5ver joomla..

Anonymous said...

logout link does not work for 3.1.5

dipak kumar burnwal said...

thanks buddy.

Unknown said...

Thank you so much!
You rock!

Anonymous said...

Thanks :)

QCS said...

thanks for share
i also want to share 7 free templates for joomla 3.0 so best for everyone

free download templates joomla 3.0

May be help something to you
thanks so much

Unknown said...

thanks for share
i love joomla so much, joomla is the best platform cms to make website so easily.
I've also to share all people some templates premium joomla free to download
free premium joomla templates
thanks so much