API16

JSession/hasToken: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 4: Line 4:




{{subst:Description:JSession/hasToken}}
 


===Syntax===
===Syntax===
Line 49: Line 49:




{{subst:SeeAlso:JSession/hasToken}}
 


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=hasToken
  category=hasToken
  category=JSession
  category=JSession
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:03, 25 March 2017

Description

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



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;
}



Examples

Code Examples