Actions

API16

JRequest/checkToken

< API16:JRequest

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Checks for a form token in the request.



Syntax

static checkToken($method= 'post')
Parameter Name Default Value Description
$method 'post' The request method in which to look for the token key.

Returns

boolean True if found and valid, false otherwise.

Defined in

libraries/joomla/environment/request.php

Importing

jimport( 'joomla.environment.request' );

Source Body

public static function checkToken($method = 'post')
{
        $token = JUtility::getToken();
        if (!self::getVar($token, '', $method, 'alnum'))
        {
                $session = JFactory::getSession();
                if ($session->isNew()) {
                        // Redirect to login screen.
                        $app = &JFactory::getApplication();
                        $return = JRoute::_('index.php');
                        $app->redirect($return, JText::_('SESSION_EXPIRED'));
                        $app->close();
                } else {
                        return false;
                }
        } else {
                return true;
        }
}



Examples

Code Examples


Advertisement