Sudo
Sudo

Reputation: 559

Tracking the user session using backbone.js

I have an application that uses backbone.js on the front end. So I had a question of how does it handle the user session? Everytime i send a GET,PUT,POST request, the user has to be authenticated else I get a error from the server side. Hence I used the Backbone.basicauth.js plugin which enables the basic authentication before any requests are sent across the server. I just need to call Backbone.BasicAuth.set('username', 'password');

But the problem here is that I need to hardcode my username and password everytime. So I wanted to know a way where in I can dynamically do that or a way in which I can track if a user is already logged in or i need to redirect him to a login page.

What if the user enters a random url instead of the home page, how will I track if he is logged in or not and how will I save the session?

Upvotes: 0

Views: 386

Answers (1)

Drew Nichols
Drew Nichols

Reputation: 49

At www.TheLadders.com we use form authentication and then drop a cookie with an encrypted token which we use to authenticate subsequent requests. We like it better than a traditional server side session approach because we can run all our servers stateless.

Upvotes: 1

Related Questions