how to make session ends after closing browser

前端 未结 1 405
北荒
北荒 2021-01-24 19:22

i used a simple session to create a login system,


this is just a p

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-24 20:04

    Simple Answer: You can't. The session exists on the server and the browser exists on the client's machine. The browser does not notify the server when it is closing. In many cases (ex: a computer failure or network disconnect), the browser is unable to notify your server even if it wanted to.

    Complex Answer: You could set a very low session timeout time (ie: 5 minutes) and update it every time the user pings the server, but this will log people out if they've been away from their keyboard for more than your timeout time.

    0 讨论(0)
提交回复
热议问题