I'm designing an authentication system that stores some hashed strings as "tokens" on the client machine
localStorage['tokens'] = [username, string1, string2, .... ]
and also associates those tokens with a row in a database table
____________________________________
| Table: current_user_sessions |
------------------------------------
| username | token1 | token2 | ... |
so that any time a user tries complete an action, the client machine queries the database asking for a row with those matched tokens and the user's name to verify that the user is logged in a valid session.
I send these tokens as variables to the php page that checks to make sure the session is valid.
$tokens = $_GET['tokens']
$session_is_valid = query_that_checks_db_for_tokens($tokens)
return $session_is_valid
Is it possible for someone to get access to another user's localStorage through an XSS attack and is this an unsafe way to keep a user session secure?