用户关闭浏览器时也会从会话表中销毁会话

I want to destroy session when I close browser in yii2, for that I used that code in web,config file:-

'user' => [
        'identityClass' => 'app\models\TblUser',

        'enableAutoLogin' => false,
        'loginUrl' => ['site/index/login'],
     ],

With the help of this code I am successfully destroyed session but at that time session table not updated. When manually I log-out user that time session table updated. Please help me when I will close browser, that time my session table also be update.

Thank you

That's not possible.

You can only tell the user's browser to discard the session cookie as soon as the browser is closed. Or in more technically correct terms - the browser is being told that it shouldn't permanently store that cookie.

But there's no way for the server to know if/when a browser is closed.

A mechanism called "garbage collection" should clear-up those old session records from your database later. It just periodically checks for expired session data and deletes it.