ใน yii2 สามารถบังคับให้ผู้เข้าเยี่ยมชม ต้องล๊อกอินทุกครั้ง ในทุกหน้าของเว็บหรือ site นั้น ๆ (backend / frontend) โดยเข้าไปที่ site/config/main.php แล้วเพิ่มเข้าไปใน components ตามตัวอย่าง
‘components’ => [
… ‘as beforeRequest’ => [ /* fource login */ ‘class’ => ‘yii\filters\AccessControl’, ‘rules’ => [ [ ‘actions’ => [‘login’, ‘error’], ‘allow’ => true, ], [ ‘allow’ => true, ‘roles’ => [‘@’], ], ], ],
…
]
[/code]
ถ้าใส่ใน common/config.php จะมี error