Answer the question
In order to leave comments, you need to log in
How to disable a session in a module?
I'm doing it in the REST API module, I need to disable sessions. Doesn't come out...
namespace app\modules\api;
class API extends \yii\base\Module
{
public $controllerNamespace = 'app\modules\api\controllers';
public function init()
{
parent::init();
$this->layout = false;
\Yii::$app->user->enableSession = false;
\Yii::$app->user->enableAutoLogin = false;
\Yii::$app->setComponents(require(__DIR__ . '/config.php'));
}
}
return [
'response' => [
'class' => '\yii\web\Response',
'format' => \yii\web\Response::FORMAT_JSON,
],
'request' => [
'class' => '\yii\web\Request',
'enableCsrfValidation' => false,
'enableCookieValidation' => false,
'enableCsrfCookie' => false,
],
];
namespace app\modules\api\controllers;
class SignalController extends \yii\web\Controller
{
public function behaviors()
{
return [
'authenticator' => [
'class' => \yii\filters\auth\HttpBearerAuth::className(),
]
];
}
public function actionIndex()
{
return ['enableSession'=>Yii::$app->user->enableSession];
}
}
public static function findIdentityByAccessToken($token, $type = null) {
return static::find()
->where(['access_token' => $token])
->andWhere(['>=', 'access_token_expires', new Expression('CURRENT_TIMESTAMP')])
->one();
}
__flash|a:0:{}
Yii::$app->session->setFlash
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question