In my list view I have added token in my form using

<?php echo JHtml::_( 'form.token' ); ?>

Then I have redirected from the list view to a controller's task like http://some/joomla/site/administrator/index2.php?option=com_users&task=edit&id=1

In the controller I checked for the token using

Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

Now when I login through backend as Super User select any item to edit then I get an error message as The most recent request was denied because it had an invalid security token. Please refresh the page and try again.

Can anyone tell me how to fix this?

When I remove the check of checkToken() it works but I don't want to remove it.

Do we need to do some additional things?

1 Answer 1


It is better if you do not just put the creation of the token in the form in list layout but you get or create the token at the redirect to the controller. Example from the docs:

JRoute::_( 'index.php?option=com_example&controller=object1&task=edit&'. JSession::getFormToken() .'=1' );

so, add . JSession::getFormToken() .'=1' to your redirect link in the view.

Then, since it is a get request (not a post request) you will check the token like:

JSession::checkToken( 'get' ) or die( 'Invalid Token' );

(instead of using JSession, you can use Session object as you do it already).

I hope this fixes the issue for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.