Actions

API15

JRequest/checkToken

From Joomla! Documentation

< API15:JRequest
Revision as of 13:44, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Checks for a form token in the request

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

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

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

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />