From my short experience, you should store in $_SESSION
only data that you will NOT need to be refreshed in all sessions opened by a unique user in different devices.
(mobile/desktop/etc.)
In other words, data that you are sure will never change like a userID.
For example, I had stored the user profile picture path into
$_SESSION
and it led to a strange User Experience. When changing the
profile picture in a desktop, it did not refresh the profile picture
for the user on his mobile. Other users saw the new picture though.
Indeed, the path was refreshed into the DB but not in the $_SESSION
.
Login-out and Login-in would not change anything.
Remember that the default behavior is that $_SESSION
passed with cookie will be different for each browser even if this is the same user logged in. You will have to do a session_destroy()
to avoid being stuck with old data.
Very temporary data may be stored in $_SESSION
as well I guess.
NB: the basic need of global session, out of these arguments, is to have variables available globally