Why Is Laravel 5.5 Session Data Lost After Loggin Out?

- 1 answer

I understand that laravel will generate a new session id when a user logs in, but in that case it retains the session data, but why does the data go away when the user logs out? So here is a method I am calling to get the CartID from the session:

public function getId()
    if (!Auth::check()) {
        if (!session()->has('CartID'))
            session()->put('CartID', session()->getId());
        return session('CartID');
    else {
        return session('CartID', '');

I pass the CartID from the above method and also the current session ID to a blade and display them. (this is just for devlopment purposes to "test" how this works.) So when I first go to website and I am NOT logged in it displays the same value for Cart ID and Session ID as one would expect. Then I login and go back to that page and then it displays the original (same) Cart ID but a new Session ID, which is also what one would expect. I have even tested completely closing my browser and reopening and when I go back I still have the original Cart ID with a different session ID (same as when it was closed). So this proves the session data is still intact after closing the browser. So far so good. However if I logout then go to the page the CartID has now changed to the new session ID, so I lost the original value of the Cart ID. This shows that when I logout I am losing all of my session data. Below is what I think might be useful from my session config file:

'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 2880,
'expire_on_close' => false,
'encrypt' => true,
'domain' => env('SESSION_DOMAIN', null),

Can anyone explain why the session data is lost after logging out? I am running php 7.1 and Laravel 5.5 Thanks in advance