-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I can't get Marty session storage to persist between tabs or Marty localStorage to work at all! #366
Comments
Also local storage doesn't seem to work for me either... Tried both on Chromium and Firefox (OSX) |
From MDN:
Do you have any more details on what you're seeing with localStorage? |
import Marty from 'marty';
class LocalStorage extends Marty.LocalStorageStateSource {
setToken(token) {
this.set('token', token);
}
getToken() {
return this.get('token');
}
logout() {
this.clear('token');
}
clear(key) {
this.storage.clear(key);
}
}
export default LocalStorage; The token never seems to be saved within localStorage though, what could I be doing wrong? |
Does it work if you use localStorage directly without using the state source? |
How can I do this, would you mind giving some code? |
Check the code here - https://github.com/martyjs/marty-lib/blob/v0.10.6/src/local-storage-state-source/localStorage.js It's pretty straightforward, just replace your state source calls with calls to |
Ok bare in mind my app is isomorphic. *I run the same code on both the server and the browser. * That being said, I tried to I get testing123 on all tabs I run this code. This is how my class looks right now. I stopped using import Marty from 'marty';
class LocalStorage {
setToken(token) {
return window.localStorage.setItem('token', token);
}
getToken() {
return window.localStorage.getItem('token');
}
logout() {
window.localStorage.clear('token')
}
clear(key) {
window.localStorage.clear(key);
}
}
export default LocalStorage; Hmm.. this is weird... Have you tested |
The state source works for me. Try adding some debug logging for the |
I'm using
this.app.session.setToken(tok);
andthis.app.session.getToken(tok);
fromthis state source.
All works well while I'm in one tab. But when I open another tab the session is lost, and getToken ALWAYS Returns null. Why?
I'm using Marty 0.10.4
The text was updated successfully, but these errors were encountered: