I closed the browser without logging off. I saw the closure of the session when I open the browser again.The session when the browser closes must also shut down. can you help me?
答案 0 :(得分:0)
Session is used to prevent to loose data when you close the browser so I don't think there is a "correct" way to do that.
You can flush your session data with
$request->session()->flush();
Otherwise you can try to delete the Laravel Cookie when you .unload() the window.
答案 1 :(得分:0)
you have to review config/session.php
check this http://www.snippetcase.com/snippet/26/Remove+session+after+closing+the+browser+in+laravel
答案 2 :(得分:0)
Laravel sessions is a server side, but browser close is a client side event. You can send additional request on browser close or just delete cookies. It will looks like:
window.onbeforeunload = function () {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
}
}