javascript - Backbone, keep a models data even after the page was refreshed -


i building rest api.

client side, use backbone.

upon authentication, api sends token via ajax on backbone's session model.

i place token using jquery's ajaxprefilter method, send token towards api on every request.

everything works perfect, until users refreshes page.

if page refreshed, token lost, model re-initializes , user has authenticate again.

how can bypass this? 1. store token inside cookie (very unsafe, bad idea) - defeats rest purpose. 2. store token inside localstorage - equally bad, believe.

is there else can done?

thank you!

you can store token both ways.

if you're using ssl, token available client (and nsa, maybe) brings no problem.

i rather store token using localstorage unless client doesn't supports it.

you can check answer keep session across page reload in backbone js


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -