API16

API16:JSession/hasToken

From Joomla! Documentation

Revision as of 22:42, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Method to determine if a token exists in the session. If not the session will be set to expired <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Method to determine if a token exists in the session. If not the session will be set to expired

[Edit Descripton]

Template:Description:JSession/hasToken

Syntax

hasToken($tCheck, $forceExpire=true)
Parameter Name Default Value Description
$tCheck Hashed token to be verified
$forceExpire true If true, expires the session

Defined in

libraries/joomla/session/session.php

Importing

jimport( 'joomla.session.session' );

Source Body

public function hasToken($tCheck, $forceExpire = true)
{
        // check if a token exists in the session
        $tStored = $this->get('session.token');

        //check token
        if (($tStored !== $tCheck)) {
                if ($forceExpire) {
                        $this->_state = 'expired';
                }
                return false;
        }

        return true;
}

[Edit See Also] Template:SeeAlso:JSession/hasToken

Examples

<CodeExamplesForm />