title: Auto redirect to the login page after inactivity of user in yii2
body: <p>I am trying to Auto-redirect the user after inactivity in the <strong><code>yii2</code></strong>.
  I have added this to my configuration.
  Currently, if the user stays inactive for 30 seconds and then clicks on any link in the application it will be redirected to the login.</p>
  
  <p>But it should Auto Redirect to the login page after inactivity of 30 seconds automatically without a click on any other places in the application.</p>
  
  <pre><code>'session' =&gt; [
          'timeout' =&gt; 30,
   ],
  'user' =&gt; [
          'class'=&gt;'yii\web\User',
          'identityClass' =&gt; 'app\models\User',
          'loginUrl'=&gt;['site/login'],
          'enableAutoLogin' =&gt; false,                        
          'authTimeout' =&gt; 30,                   
      ],
  </code></pre>
  
  <p>I have tryied this in above code but it will gives 404 error.</p>
  
  <pre><code>'loginUrl'=&gt; Yii::$app-&gt;response-&gt;redirect(['site/login']),
  </code></pre>
  
  <p>So how should i redirect <strong>automatically</strong> after 30 second if <strong>inactivity</strong>. </p>