Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8096923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:35:42+00:00 2026-06-05T21:35:42+00:00

I was wondering how can I track the current logged in user in a

  • 0

I was wondering how can I track the current logged in user in a backbone.js app, Most of the views on the page need to know if the user is logged in or now and which user is logged in. What is the best method to achieve this?

I have session management on the server but how do I know which user am I dealing with in my backbone app and how do I know if he logged out thats the question

Also how do I know that a user has logged out using another tab etc? There should be a generic way to handle this stuff, like we have before filters in rails to manage such things. What method is used to achieve the same on the front end.

What I am currently doing is that when the homepage loads I have set from my server side rendered html a hidden field #current_user_id, which the my backbone app reads and sets a variable like the follwoing

window.MyApp =
  Models: {}
  Collections: {}
  Views: {}
  Routers: {}
  currentUser: null
  init: -> 
    @currentBusiness = $('#current_business').val()
    new MyApp.Routers.Businesses
    Backbone.history.start()

$(document).ready ->
  MyApp.init()

Then my router sets up a ShowView which then sets ups other sub views on the page

class MyApp.Routers.AppRouter extends Backbone.Router
  routes:
    '': 'show'

  show: ->
    user = new Vocallocal.Models.user id: Vocallocal.currentBusiness
    Vocallocal.currentBusiness = business
    new Vocallocal.Views.BusinessesIndex model: business
    business.fetch()

Here is the main ShowView

class MyApp.Views.ShowView extends Backbone.View 

  el: '#main'
  template: JST['users/home'] 

  initialize: ->
    @model.bind 'change', @render, @
    @details = new Vocallocal.Views.UserDetails model: @model 
    @logo = new Vocallocal.Views.UserLogo model: @model 
    @managePhotos = new Vocallocal.Views.ManagePhotos model: @model 

  render: -> 
    console.log('change has occured') 
   @

does the above code and setup makes sense. I am looking on general advice if I should make any changes to the above.

Thank you for you valuable input

–Abid

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:35:44+00:00Added an answer on June 5, 2026 at 9:35 pm

    I also battled wrapping my head around authentication when developing client side apps. If you have ever worked with a 3rd party API (Facebook, Twitter) you will know that all authentication is done on the server side. Thats why @Pointy is correct. No authentication is done client side.

    So If you are looking to access a secure part of your API, your username and password must be sent with every request, and checked on the server. This is definitely not the most secure way, and there are very few ways to get around this without an HTTPS connection. I am not sure what language you are developing your API in, but still this link is a very good read. Steve basically uses a simple protocol whereby the client sends an authorization token as a header in the HTTP request, and the server decodes that token to decide whether or not it is valid.

    In answering your question, I would check if the user is valid. If he/she is, bootstrap your user model with an authentication token. This authentication token will be sent and decoded with every api request that requires authentication. I am no expert, so if there is any other way, please let me know. I am also still learning this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if you know if Google Analytics can track not just where
i've developped a multilanguage site and now i'm wondering how i can best track
I was wondering how can I list the user tables name with its primary
With google analytics you can track ecommerce events, http://code.google.com/apis/analytics/docs/tracking/gaTrackingEcommerce.html I was wondering if this
I was wondering whether it was possible to obtain the current user object and
is there a way to track an event, on which page it was assign
was wondering how can I create a sub drop down box upon selecting a
I was wondering how can I control the image on the connect dialog? I
i'm wondering how can I compare in C language, a number I put on
I was wondering how can I do something similar to Facebook when a link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.