Edwin Aw
Edwin Aw

Reputation: 130

Old Session Isn't Flushed with Session::regenerate

I need some information about how Laravel cache session.

I am using file based Laravel session.

Scenario:

  1. Run the web once to create the session in storage/framework/sessions.
  2. Put some value in Session.
  3. Delete that physical session file from storage/framework/sessions.
  4. Refresh the site, and see a new physical file with exact session Id filename as before recreated, as well as all the data from previous session being restored to this new file.

My question is, where does Laravel store the session data? How to effectively erase the session data so that even a whole new physical session file recreated with the same filename wouldn't restore the old data.

The above issue has been resolved.

Another issue arise, running below code:

Session::forget('member');
Session::flush();
Session::regenerate();

The old session wasn't flush at all, all the data is still there. But the newly generated session start fresh.

How can I really flush the old session before moving to new session?

Upvotes: 0

Views: 1284

Answers (2)

Edwin Aw
Edwin Aw

Reputation: 130

Below is the correct way to persist the new data in old session:

Session::forget('member');
Session::flush();
Session::save(); // trigger save to old session

Session::regenerate(true); // pass true to regenerate would delete the old session file.

Upvotes: 1

Amado
Amado

Reputation: 383

Under default settings your sessions are stored in a table called 'sessions' in your default database connection

destroy it

Upvotes: 0

Related Questions