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

  • Home
  • SEARCH
  • 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 7852075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:19:56+00:00 2026-06-02T19:19:56+00:00

I am building a web application with a back and front end, the backend

  • 0

I am building a web application with a back and front end, the backend is build in scala, the frontend build in html, css, jquery (backbone.js, jquery.js, underscore.js).

How can I create a login? So basically you can see the frontend as an app, we only make json requests to the rest backend.

Thanks for help.

  • 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-02T19:19:58+00:00Added an answer on June 2, 2026 at 7:19 pm

    Scala or not, JSON or not, XHR or not the mechanism is still the same. You send login and password to the server (salt-hash the password on the client-side to make it safer), server authenticates it (checks if login and password match the one in db), then it creates a session for the user (in DB or in memory – depending on your needs) and sends the session ID to the user as a cookie (AJAX requests/responses should work correctly with cookies).

    Now on every request you check for the session cookie and verify if it points to the valid user (i.e. if it points to anything). Logout is as simple as deleting the session entry with given ID. The ID should be created in such a way that first: it is long (to minimize threat of session hijacking) and second: it contains the date encoded (so you can clean expired sessions).

    This is so called Form-based Authentication.

    // EDIT

    Let me answer the questions in comments. How does session work?

    Server creates session. Session is nothing else then table in DB with 2 columns: ID and Value (here you will hold session data encoded in JSON and compressed if necessary like for example things you want to buy from eShop). When client is successfully authenticated server send the session ID to the user via cookies. So server has to add the following header to the response:

    Set-Cookie: session=ID32445235423tdwfnmm; Expires=Wed, 09 Jun 2012 10:18:14 GMT
    

    Now the browser understands this header and sets the cookie for client. From this point whenever you make a request the browser automatically adds cookies to the request, so every request from now on will have the following header

    Cookie: session=ID32445235423tdwfnmm; other_cookie:other_value;
    

    unless the date is after Wed, 09 Jun 2012 10:18:14 GMT. If this is the case then our session cookie will be omitted (note that this is not the same as destroying session on the server side which you have to handle manually).

    Now you have to decode the Cookie header on the server side and retrieve the ID. Using some framework is a great idea at this point, because it is a bad practice to write decoding code in every request. You should use so called middleware here. Now this middleware retrieves the ID, checks the DB for session and stores the result (i.e. user is authenticated or not) in request object to be used later (i.e. in the final request handler).

    So as you can see you don’t use JavaScript at all.

    Also you set the cookie only on login request (although you can set it on every request to minify session hijacking problem – but that’s even more complicated). It is browser’s job to store the ID. On server side you only check if the Cookie header contains session key.

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

Sidebar

Related Questions

I’m building a J2EE web application which uses Oracle SSO with an OID back-end
I have a web application that needs a database back-end. My back-end is really
I'm building a model view controller web application and I want to build a
I'm building an HTML5 application (with ASP.NET back-end) and i want to develop it
I am building an ASP.NET MVC web application and I'm using jQuery for some
I am building a Web Application using asp.net (C#). I come from windows forms
I am building a web application that will need to allow users to save
I am building a web application that needs to print directly from browser, however,
I am building a web application that has a real-time feed (similar to Facebook's
I am building a web application using ASP.NET MVC that has two very distinct

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.