Dani Queiroga
Dani Queiroga

Reputation: 59

Joomla invalid token message

since this new EU cookies privacy law came out, i had to implement a plugin on my website that block all cookies on my website till the user accept. The problem here is that some users dont accept the cookies but even so they try to login, and then they get that blank page with invalid token message. Theres nothing good on that invalid token message, i would like to redirect those users who get this message to a ustom page, i managed to find the code but i mjust dont know how to change it to redirect the user, heres the code:

function login()
    {
        // Check for request forgeries
        JRequest::checkToken('request') or jexit( 'Invalid Token' );

        global $mainframe;

        if ($return = JRequest::getVar('return', '', 'method', 'base64')) {
            $return = base64_decode($return);
            if (!JURI::isInternal($return)) {
                $return = '';
            }
        }

i believe i have to use the "header: location" thing but just dont know how to implement that on the current code.

Hope someone can point me for a clue

Best regards

Upvotes: 0

Views: 1140

Answers (1)

Marko D
Marko D

Reputation: 7576

You could use Joomla redirect function.

function login()
    {
        // Check for request forgeries
        if(!JRequest::checkToken('request')) {
            $app = JFactory::getApplication();
            $app->redirect('index.php', 'Invalid token. You must accept cookies in order to use this website'); 
        }

        global $mainframe;

        if ($return = JRequest::getVar('return', '', 'method', 'base64')) {
            $return = base64_decode($return);
            if (!JURI::isInternal($return)) {
                $return = '';
            }
        }

Upvotes: 2

Related Questions