Skip to content

Can't access keys after refresh when using local storage #3

Description

@deepc0py

When using local storage, if I set keys and refresh the keys show with the right data in the Session but aren't accessible with Session.get('key');
At the start of app, I set config and print the session object like so:

function App() {
useEffect(() => { Session.config(true, 60); }, []);

console.log(Session);
console.log(Session.items());
console.log(Session.get('username'));
console.log(Session.get('id'));
console.log(Session.get('username'));
console.log(Session.get('email'));`
...
}

But here is the result:
Screen Shot 2022-04-12 at 8 02 09 PM

In my Login.js when I set the keys and console.log them, they show up just fine.
if (res.data) {
Session.set("id", res.data.id);
Session.set("username", res.data.username);
Session.set("email", res.data.email);
Session.set("accessToken", res.data.accessToken);
console.log(Session);
console.log(Session.get('id'));
console.log(Session.get('username'));
console.log(Session.get('email'));
}

Screen Shot 2022-04-12 at 8 04 08 PM

Any idea what I'm doing wrong?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions