会话被维护或销毁?

I am confused regarding Session in PHP. My question is when a user closes directly red cross button without logging out whether the session is destroyed or not. If he again opens that page whether he would be asked to login or he would be directed inside the application?

I have googled around, some are saying it will be directed to login and same are saying it will be directed inside the application.

PHP sessions should automatically expire when the browser window closes providing you do not modify the Session Cookies expiration time.

moreover whatever scene you described can be done by Cookie

if you set cookie (persistent) for a limited time period then it will not ask for the login untill that and save your login credentials.

redirecting on the last page can be done by your logic not by browser.

check that session.cookie_lifetime in php.ini if it is 0 means whenever we close the browser. it will destroy the session

more info

The default session cookie is set to expire when the browser window is closed. The corresponding session on the server will still exist for a while until it is garbage collected. If the user could resurrect/keep the cookie, he could continue to use the session. But again, the browser will discard the cookie when it's closed. You can modify the session cookie settings with an explicit expiration time, which means it will persist until then, giving your user a permanently logged-in status.

Here are all the session and session-cookie related settings you can tweak with ini_set: http://php.net/manual/en/session.configuration.php