#54445Session data can't be fetched for non authenticated fe_users
Description
Hi again,
as i need to store some data in session (basket items) for users visiting website i have created a little service to handle session action. All seems to work just fine for authenticated fe_user. The problems start with guests that are not authenticated.
Their data lands in ‘fe_session_data’ table identified by unique hash and this hash is a problem here. On each page reload its different – the $id (that is hash in fe_session_data table) changes in TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication – so the saved data is never fetched.
On line 406 we have:
@// If new session or client tries to fix session…
if (!$id || !$this->isExistingSessionRecord($id)) {
// New random session-$id is made
$id = $this->createSessionId();
// New session
$this->newSessionID = TRUE;
}@
and the $this->isExistingSessionRecord($id) always returns false for not authenticated user as it checks for session in ‘fe_sessions’ table where records are created only for authenticated users (method createUserSession() is calle donly for authenticated user)!
So all this results with this:
if we set some data to be stored in ‘fe_session_data’ (not authentictated user) it is put there on each reload as it cant find it because hash ($id) changes each time!
I hope this can be fixed and i did not missed something to make session works for not authentictated users.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.