Laravel's exact token changes on every update

Passing these questions. The session is stored correctly, the file is not changed, and the session still exists. The session lifetime in the Config file is 120. However, my session array _token key changes value on every update, so it can't output the correct session that was written.

What can cause the session token to change on every refresh on the page?

Session immediately after redirecting to LoginController.php

array:7 [▼
"_token" => "7bcBy6cPKpMO0BBUvrVOUPd3YHmCSoMEpxHWLcvk"
"_previous" => array:1 [▶]
"flash" => array:2 [▶]
"login_82e5d2c56bdd0811318f0cf078b78bfc" => 78
"username" => "demo"
"Account" => "demo"
"Auth" => array:1 [▶]
]

      

Session array after first update:

array:1 [▼
"_token" => "o5l9uGjjmVwr5vZXC5MZH3GaClYXW1OxarWVN7p5"
]

      

Session array after second update:

array:1 [▼
"_token" => "i5IFTEWM6txuNPSFL6SMa3a2gUrQzciREd8pUp4K"
]

      

As you can see, the _token keeps changing and the rest of the session data is erased. What could be causing this?

UPDATE: So I tested different session drivers. I have tested file, database and cookies. They all don't save session data. What can cause the session data to be erased or loaded incorrectly?

UPDATE 2: So I ran into something very interesting. It's Chrome that's the problem. When running this app in firefox, the sessions work fine. What can cause Chrome to lose session data?

+3


source to share


2 answers


So the problem was something like Arthur. This is because the old session cookie just overwrites the session even when the cache is cleared and the driver types change. After clearing the lifetime cookies of chrome, it started writing and saving the session correctly. This was a completely new mistake for me.



-1


source


The session token is stored (client-side) via cookies. Check your chrome config.

go to:

chrome://settings/

      

Click the link:



show advanced settings...

Privacy > Content Setting...

      

The default selected option is:

Allow local data to be set (recommended)

      

If the local data is locked, chrome will require a new authentication on every update, which causes laravel to provide new tokens just like you did.

0


source







All Articles