HackIndia Logo
HackathonsNewsSkillsGrowth
HackIndia LogoContact: +91 9910125804

General

  • Companies
  • Colleges
  • Board of Advisors
  • Brand Ambassadors
  • FAQ
  • Contact
  • Report a Bug

Hackathons

  • Upcoming Hackathons
  • Judges
  • Mentors
  • Partners
  • Participating Colleges

Resources

  • About Us
  • Branding
  • Latest News
  • Growth
  • Skills
  • Ecosystem
  • Forum
  • Ideas
  • Prompt Optimizer
  • How to earn XP

© 2026 HackIndia. All rights reserved.

Privacy PolicyTerms of ServiceCode of ConductSitemap

Build 2.139 · 09 Nov 2026, 10:59 UTC

    HackIndia
    HackathonsNewsInternshipsSkillsGrowth
    Working towardsAuthentication
    0%

    0 of 9 steps done · +100 XP · +50 SHARP when it is yours

    1. 1Avoid the common auth traps4 min · +10 XP · +5 SHARP
    2. 2Hash passwords correctly4 min · +10 XP · +5 SHARP
    3. 3Choose sessions or tokens5 min · +10 XP · +5 SHARP
    4. 4Use cookies safely4 min · +10 XP · +5 SHARP
    5. 5Add OAuth sign-in4 min · +10 XP · +5 SHARP
    6. 6Protect routes and data4 min · +10 XP · +5 SHARP
    7. 7Ship an auth-ready repo4 min · +10 XP · +5 SHARP
    8. The check10 questions, 7 to pass · +10 SHARP
    9. Hand in the taskA project that uses the skill
    10. Skill and certificate+100 XP · +50 SHARP
    Lesson 3 of 7 5 min

    Authentication

    Choose sessions or tokens

    • +10 XP for this lesson
    • +100 XP when the skill is proved
    • 3 learning it right now
    In 30 seconds
    • Pick sessions or tokens based on your app, not trends.
    • Explain where auth state lives and how logout works.
    Add a short auth-choice note to your README.
    Key point

    Main choice

    Use sessions for most server-rendered web apps. Use tokens when your API must be called by separate clients like a mobile app, another backend, or a separate frontend domain.

    The real question is simple: where will you store the signed-in state, and how will you revoke it when the user logs out?

    What sessions mean

    With sessions, the server stores the login state. The browser only keeps a random session ID, usually in a cookie.

    On each request, the server reads the session ID, looks it up, and knows the user. Logout is easy because the server can delete that session.

    What tokens mean

    With tokens, the client stores a signed token. The server checks the token on each request and trusts its contents if the signature is valid.

    Tokens are common for APIs and mobile apps. Logout is harder because a valid token can remain valid until it expires, unless you add a denylist or use short expiry with refresh tokens.

    Your to-do

    Choose by app shape

    Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.

    0 of 5 done

    Common mistake

    Common mistake

    Do not use JWTs only because they sound more advanced. A JWT is not automatically safer than a session.

    Also do not store long-lived tokens in localStorage without thinking through theft by injected JavaScript. You will handle storage details in the cookie lesson, but your choice starts here.

    Example

    README note

    Add a small section like this to your repo. It tells a recruiter that you made an auth design choice, not just copied a package setup.

    Auth choice
    
    This app uses server-side sessions.
    
    Reason:
    - The app is a normal web app with browser users.
    - The backend can store and revoke sessions.
    - Logout deletes the server session, so access stops immediately.
    - The browser only receives a session id, not the user password or user record.
    
    Security checks:
    - Passwords are hashed before storage.
    - Protected pages check the session before returning user data.
    - Session cookie settings are documented in the cookie section.
    Tip

    Ask AI well

    AI can help you compare choices, but give it your app shape. Ask for risks, not just code.

    Check the answer for three things: where state is stored, how expiry works, and how logout or revocation works.

    Prompt:
    I am building a web app with Express and React for college event registrations.
    Users sign in from a browser. The backend and frontend are on the same domain in production.
    Should I use server-side sessions or JWT access tokens?
    Compare storage, logout, expiry, and what I should write in my README.
    Your to-do

    Do this now

    Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.

    0 of 5 done

    Quick check

    0 of 2 right
    1.Your app is a normal browser web app, and you want simple logout controlled by the backend. What is the better default?
    2.What should your README explain when you choose sessions or tokens?

    Answer the quick check to finish this lesson.

    ← Lesson 2Skip to lesson 4 →
    Working towards
    Authentication +100 XP

    0 of 7 lessons done · proved by a project that uses the skill

    See the track