Localstorage variables shift to database instead

Does it make sense to store my localstorage variables on the database instead? I am using these variables to connect to my xmpp server. And If the user only closes the browser but comes back then use the cookie to identify the user and get him from the database, and then use the local storage variables to conenct back to the xmpp server using javascript.

Connection to the xmpp server is happening only via the browser.