Localstorage is designed to save the client part of the data so that it can be accessed even if the client is offline, in which case, as you said, it accesses JavaScript.
PHP sessions store information on a server. Using localStorage is also a bad idea, as it can be modified by the client, so the client can claim to be registered as another user, which is obviously a security issue.
Is there a problem with your PHP configuration? Is there a timeout value for a PHP session cookie that you can change?
source
share