PHP code example of yii1tech / session-dummy

1. Go to this page and download the library: Download yii1tech/session-dummy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yii1tech / session-dummy example snippets




return [
    'name' => 'Test Application',
    'components' => [
        'session' => [
            'class' => yii1tech\session\dummy\DummySession::class,
        ],
        // ...
    ],
    // ...
];



namespace app\web\controllers;

use app\oauth\AuthUserByTokenFilter;
use CController;
use Yii;
use yii1tech\session\dummy\DummySession;

class ApiController extends CController
{
    public function init()
    {
        parent::init();
        
        Yii::app()->setComponent('session', new DummySession(), false); // mock session, so it does not send any Cookies to the API client
    }
    
    public function filters()
    {
        return [
            AuthUserByTokenFilter::class, // use custom identity to authenticate user via OAuth token inside {@see CWebUser}
            'accessControl', // now we can freely use standard "access control" filter and other features
        ];
    }
    
    public function accessRules()
    {
        return [
            // ...
        ];
    }
    
    // ...
}