"Invalid Token" error after upgrade!

Joomla versions 2.5, 1.7 and 1.6 are all end-of-life since December 31st 2014 and are no longer supported. Please use Joomla 3.x instead.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
User avatar
DC_Navan
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 217
Joined: Thu Feb 10, 2011 4:05 pm

"Invalid Token" error after upgrade!

Post by DC_Navan » Tue Mar 08, 2011 4:01 pm

Hello all!

I have just upgraded to 1.6.1 and everything seemed fine but when I try to log out I get an "Invalid Token" error on the screen.

I am using LDAP to auth login.

Has anyone else had similar problems?

8)

robulus
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Wed May 07, 2008 5:30 am

Re: "Invalid Token" error after upgrade!

Post by robulus » Wed Mar 09, 2011 2:04 am

Hi, yes I got this error. They've added a token to the logout process now, so if you are using a template override for any logout form, you'll get this error. You need to find your template override, which is in templates/<youTemplateName>/html/mod_login (or other module / component that has a logout button) and edit the default.php file. The form for the logout button needs to include this line:
<?php echo JHtml::_('form.token'); ?>

Do that and you should be good to go.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 39126
Joined: Sat Apr 05, 2008 9:58 pm

Re: "Invalid Token" error after upgrade!

Post by Webdongle » Wed Mar 09, 2011 2:13 am

Try clearing your Browser cache or switching off your PC, counting to 20 and switch it on again.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein.

User avatar
DC_Navan
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 217
Joined: Thu Feb 10, 2011 4:05 pm

Re: "Invalid Token" error after upgrade!

Post by DC_Navan » Wed Mar 09, 2011 10:00 am

Thank you so much robulus!!! :laugh:

I was about to reinstall the old joomla until your solution worked!

Also thanks to Webdongle for the sugestion.

For anyone else unsure, here is the bit that I pasted it into to get it working:


<div align="center">

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

<input type="submit" name="Submit" class="button" value="<?php echo JText::_('JLOGOUT'); ?>" />
</div>




Thanks again guys!
:pop

rjdevries
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Tue Nov 18, 2008 11:07 am

Re: "Invalid Token" error after upgrade!

Post by rjdevries » Thu Mar 10, 2011 8:28 am

Thanks robulus!!
Maybe a template override check while updating would be a good future.
That can not be very difficult.

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Wed Mar 16, 2011 6:22 pm

Can you say where exactly this code should go in the default.php code?

I am having trouble logging out from the front end (invalid token) should this code go in the template:

html/mod_login/default.php

OR

the joomla dir

plugins/system/logout/logout.php?

thanx ???

notdan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sun Feb 25, 2007 3:40 pm

Re: "Invalid Token" error after upgrade!

Post by notdan » Thu Mar 17, 2011 3:34 pm

hi robulus and dc_navan,

thanks for the tip :) .

had the same problem, but could solve it with your code.

@craiggf: i added the code in templates/mytemplate/html/mod_login/name of my alternative layout (seems to be default.php in your message).

ajakoan
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Thu Feb 10, 2011 12:04 am

Re: "Invalid Token" error after upgrade!

Post by ajakoan » Thu Mar 17, 2011 5:49 pm

I encountered this problem as well, but was not using a template override.

I was using a login/register module extension. I pasted the suggested code into the form in that module's (default.php) and it worked thanks!

Just to clarify where I pasted, in modules/mod_loginregister/tmpl/default.php:

After:

<?php if($type == 'logout') : ?>

<form action="<?php echo JRoute::_('index.php', true, $params->get('usesecure')); ?>" method="post" id="login-form">

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

Vihotar
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Mar 05, 2011 7:53 am

Re: "Invalid Token" error after upgrade!

Post by Vihotar » Fri Mar 18, 2011 1:13 pm

I have installed jomsocial with joomla 1.6.1

Above method solves problem for standard joomla logout but i can't logout using jomsocial's logout an it is saying same error "Invalid Token".

Jomsocial's logout works perfect with joomla 1.6.0 but with joomla 1.6.1 it has same problem which joomla standard logout has.

Anybody know how to fix this?

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Sat Mar 19, 2011 4:59 pm

find the login module Social is using , if it is the login module (1.6.1 added the TOKEN) then below is your fix....(at least it worked for me, I had to change it in my templates code....)

The code block is below to make it easier to find, the only change/addition is the last line (which I bolded and italicized).

<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="user.logout" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
<?php echo JHtml::_('form.token'); ?>

:D

kapeman
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Apr 19, 2007 4:43 pm

Re: "Invalid Token" error after upgrade!

Post by kapeman » Mon Mar 21, 2011 6:49 pm

Same problem here, except that my install is a clean 1.6.1 install, no upgrade.

I am using the businesslab-default template and not using a login module.

In fact, I have the login module unpublished.

I get the error when logging out of admin.

Also, there is no mod_login folder for this template.

User avatar
DC_Navan
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 217
Joined: Thu Feb 10, 2011 4:05 pm

Re: "Invalid Token" error after upgrade!

Post by DC_Navan » Tue Mar 22, 2011 4:23 pm

kapeman wrote:Same problem here, except that my install is a clean 1.6.1 install, no upgrade.

I am using the businesslab-default template and not using a login module.

In fact, I have the login module unpublished.

I get the error when logging out of admin.

Also, there is no mod_login folder for this template.


See my post above mate.
It could be caused by your template still using the old style.

Change the front-end and back-end template settings to the default and see what happens.

8)

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Tue Mar 22, 2011 7:48 pm

You have to have a login module activiated somewhere as you are logging into the site, I am not familiar with the template? Where is it from I don't remember the template mentioned for 1.6.1??
Find the login module that your site is using.....
8)

oops, you mean you do not have the front end login mod published....duhhh....got it now :-[ , what template do you have as default for administration?

kapeman
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Apr 19, 2007 4:43 pm

Re: "Invalid Token" error after upgrade!

Post by kapeman » Tue Mar 22, 2011 7:56 pm

DC_Navan wrote:
kapeman wrote:Same problem here, except that my install is a clean 1.6.1 install, no upgrade.

I am using the businesslab-default template and not using a login module.

In fact, I have the login module unpublished.

I get the error when logging out of admin.

Also, there is no mod_login folder for this template.


See my post above mate.
It could be caused by your template still using the old style.

Change the front-end and back-end template settings to the default and see what happens.

8)
Changed both templates to default and still get the error.

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Wed Mar 23, 2011 12:25 am

DC_Navan...OK,
I just installed your template (from http://downloadfiles.co/free-joomla-1-6 ... usinesslab )
on a 1.6.1 test site logged in and out of the admin backend ok.
What is the exact error your getting:

kapeman
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Apr 19, 2007 4:43 pm

Re: "Invalid Token" error after upgrade!

Post by kapeman » Wed Mar 23, 2011 12:41 am

craiggf wrote:DC_Navan...OK,
I just installed your template (from http://downloadfiles.co/free-joomla-1-6 ... usinesslab )
on a 1.6.1 test site logged in and out of the admin backend ok.
What is the exact error your getting:

Error:

"The most recent request was denied because it contained an invalid security token. Please refresh the page and try again."

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Wed Mar 23, 2011 12:47 am

I can only think something is corrupt or your sever is lacking something, altho I can not imagine what.
If you send me and email with your email address, (you don't have on at the forum listings,OR list one in your profile in the forum, that way you can send and receive thru the forum login) I will send you tempsite and login. it is a test site and you can not hurt it.....it gets reinstalled frequently
8)

kapeman
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Apr 19, 2007 4:43 pm

Re: "Invalid Token" error after upgrade!

Post by kapeman » Wed Mar 23, 2011 2:59 am

craiggf wrote:I can only think something is corrupt or your sever is lacking something, altho I can not imagine what.
If you send me and email with your email address, (you don't have on at the forum listings,OR list one in your profile in the forum, that way you can send and receive thru the forum login) I will send you tempsite and login. it is a test site and you can not hurt it.....it gets reinstalled frequently
8)
Just updated my forum preferences...

User avatar
DC_Navan
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 217
Joined: Thu Feb 10, 2011 4:05 pm

Re: "Invalid Token" error after upgrade!

Post by DC_Navan » Wed Mar 23, 2011 9:29 am

It's all good craiggf! :D

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Wed Mar 23, 2011 6:31 pm

kapeman

info sent.......

8)

kapeman
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Apr 19, 2007 4:43 pm

Re: "Invalid Token" error after upgrade!

Post by kapeman » Thu Mar 24, 2011 12:04 am

craiggf wrote:kapeman

info sent.......

8)
I got your email, but the supplied credentials were invalid.

Thanks, by the way for your help, it is very much appreciated.

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Thu Mar 24, 2011 1:31 am

senility kicking in, sent you good ones, my typing is getting worse and worse

8)

kapeman
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Apr 19, 2007 4:43 pm

Re: "Invalid Token" error after upgrade!

Post by kapeman » Thu Mar 24, 2011 1:52 am

craiggf wrote:senility kicking in, sent you good ones, my typing is getting worse and worse

8)
Well, I hate to burst your bubble, but your typing is still off.. :laugh:

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Thu Mar 24, 2011 2:03 am

It is not my typing, it is my flakey eyesight........ :-[

User avatar
crossmr
Joomla! Intern
Joomla! Intern
Posts: 50
Joined: Sun Apr 03, 2011 6:07 am
Location: Seoul, South Korea

Re: "Invalid Token" error after upgrade!

Post by crossmr » Sun Apr 03, 2011 6:11 am

Hey guys. I'm having a similar problem to this, but it's only affecting it in one spot.
I'm using Yougrids template, through which I've loaded the login form as a module on the menu that slides out.
The menu item itself is also clickable to take you through to a login page

If you need to see what I'm talking about, you can see their demo here:
http://joomla-16-templates.youjoomla.in ... -positions

The issue I'm having is that when I log out of the slide-out login menu, I get an invalid token.
if I click through to the same login form and log-out there.
it's fine.
I tried adding <?php echo JHtml::_('form.token'); ?>
as noted above to my default.php in
mod_login/tmpl
but it made no difference.
Using Joomla 1.6
any thoughts?

[edit]
sorry guys, I missed this piece of info first time through
@craiggf: i added the code in templates/mytemplate/html/mod_login/name of my alternative layout (seems to be default.php in your message).
I changed this one instead and it's now working fine.

User avatar
craiggf
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Sun Dec 09, 2007 3:30 pm

Re: "Invalid Token" error after upgrade!

Post by craiggf » Sun Apr 03, 2011 4:17 pm

My post was in reference to using JoomlaShack pro templates. I stick with them so far.
It seems to be the login module that the sites particular setup is using. Apparently different templates/extensions take over the default login function, seems to be there should be a standardized requirement here, or am I missing something here and that is where the new overrides come in? I'm still having trouble wrapping my brain around that....

8)

Fhernd
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Fri Aug 06, 2010 1:36 pm

Re: "Invalid Token" error after upgrade!

Post by Fhernd » Mon Apr 04, 2011 6:13 pm

Thanks ajakoan. I have followed your instructions, and now my Joomla site is working fine!

User avatar
Streetboards
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Apr 08, 2011 6:00 am
Location: Gold Coast, Australia
Contact:

THANK YOU!

Post by Streetboards » Fri Apr 08, 2011 6:02 am

Thank you for this fix!

I created an account on this forum just so I could say thank you! I too had this problem after upgrading to Joomla 1.6.1 using the Yougrids template. Your fix solved it, easy.

Cheers! 8)
Doomsday Streetboarding Australia
http://www.streetboarding.org

User avatar
beneberle
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Sep 11, 2008 2:47 pm
Location: New Orleans

Re: "Invalid Token" error after upgrade!

Post by beneberle » Fri Apr 22, 2011 1:57 pm

I began seeing this error after upgrading from J1.6.1 b/c I had made a copy of the Bluestork default admin template in order to customize the look of the back end. The fix for me was indeed adding the token, but in a slightly different way than listed above since I'm not using any overrides.

In 2 files:
- index.php
- cpanel.php

find the following:

Code: Select all

$logoutLink = JRoute::_('index.php?option=com_login&task=logout');
and replace with:

Code: Select all

$logoutLink = JRoute::_('index.php?option=com_login&task=logout&'. JUtility::getToken() .'=1');

jesseraymond
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Aug 23, 2011 5:14 pm

Re: "Invalid Token" error after upgrade!

Post by jesseraymond » Tue Aug 23, 2011 5:27 pm

THANK YOU CRAIGGF! Here's a solution that worked for me (including a neat little add to show/hide the logout button based on if the user is already logged in or not)

Apply this directly to your template's index.php wherever you would like the logout button to go:

Code: Select all

<?php
			$user = &JFactory::getUser();
			$userId = $user->get('id');
			if ($userId != 0) :
			?>
                        <div id="logout">
                            <form method="post" action="/your-template-name/index.php/component/users/?task=user.logout">
                                <div>
                                    <button class="button">Log out</button>
                                    <input name="return" type="hidden" value="aW5kZXgucGhwP29wdGlvbj1jb21fdXNlcnMmdmlldz1wcm9maWxl" />
                                    <input name="61fb87377e48c1f51fc25a1917dfeea6" type="hidden" value="1" />
                                    <input type="hidden" name="option" value="com_users" />
                                    <input type="hidden" name="task" value="user.logout" />
                                    <input type="hidden" name="return" value="<?php echo $return; ?>" />
                                    <?php echo JHtml::_('form.token'); ?>
                                </div>
                            </form>
                            <jdoc:include type="modules" name="logout" style="xhtml" />
                        </div>
		<?php endif; ?>  
This will also add a dynamically shown/hidden Logout module position, in case you want to add more than just a button.

Also, for those curious about why the token is recently required for logging out, here's a forum thread I found in the process of solving this that helped answer that question for me:
http://groups.google.com/group/joomlabu ... e2f301cd65

Thanks again, and Happy Joomla'ing.
Last edited by jesseraymond on Thu Aug 25, 2011 12:38 am, edited 1 time in total.


Locked

Return to “Migrating and Upgrading to Joomla! 2.5”