API16

JSession/hasToken: Difference between revisions

From Joomla! Documentation

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>[...
 
m clean up
Line 2: Line 2:
Method to determine if a token exists in the session. If not the session will be set to expired
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>[[Description:JSession/hasToken|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JSession/hasToken}}
 
{{subst:Description:JSession/hasToken}}


===Syntax===
===Syntax===
Line 50: Line 48:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JSession/hasToken|Edit See Also]]<nowiki>]</nowiki>
{{subst:SeeAlso:JSession/hasToken}}
</span>
{{SeeAlso:JSession/hasToken}}


===Examples===
===Examples===

Revision as of 14:23, 24 March 2017

Description

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


{{subst: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;
}


{{subst:SeeAlso:JSession/hasToken}}

Examples

<CodeExamplesForm />