How do server side authentication sessions work (express & cookies)

Поделиться
HTML-код
  • Опубликовано: 2 фев 2025

Комментарии • 54

  • @aissa.bouguern
    @aissa.bouguern 2 года назад +40

    I really like how you explained sessions without relying on "express-session" or any third-party library that abstracts the work done behind the scenes.
    This helps beginners to adopt a nice and very simple mental model about what sessions are about.
    Thank you so much!

  • @Goofy8907
    @Goofy8907 9 месяцев назад +1

    DUDE, this is how you explain something
    Very well done, I just came from another video on the same topic, watched the whole thing and was still clueless.
    Watched your video for like 3 minutes and had most of my questions answered, kept watching because of how well you explained.
    Thank you, I'm subscribing.

  • @mossabDiae
    @mossabDiae 5 месяцев назад

    Cody, that was beautifully explained.
    The note you added at the end about why JWT would be useful is a gem. Subscribed.

  • @jorgeenriqueecheverria5165
    @jorgeenriqueecheverria5165 2 месяца назад

    Direct to the core, no BS content! Thanks!

  • @devnarula6733
    @devnarula6733 9 месяцев назад

    exactly what I was looking for, appreciate such low level bare-bone session auth for understanding instead of just using some plugin which teaches no one anything!

  • @JoelGrayson
    @JoelGrayson 2 года назад +6

    Thank you for the simple explanation. Helped me a lot.
    Tip: res.clearCookie() does the same thing as res.set('Set-Cookie', `session=null`)

    • @bitsplode
      @bitsplode 2 года назад

      whats the difference? Number one wipes the cookie out of existance and number 2 just null-ifies it???

    • @jperusm
      @jperusm 11 месяцев назад

      @@bitsplode that is correct. number two will just "modify" the cookie value but will not delete it.

  • @perelium-x
    @perelium-x 8 месяцев назад +2

    TYSM man. I've been struggling trying to understand how sessions work with cookies

  • @marksheard1210
    @marksheard1210 Год назад

    Awesome stuff, Thank you Cody!!!
    I have been using passport-local and figuring my way round. I highly recommend going through THIS BASIC overview before leaning on other modules\packages like passport-local and express-session.

  • @HassanChakkour
    @HassanChakkour Год назад +3

    You sir deserve all the support, thank you so much, you pretty much saved me time. Great work

  • @kosidinna_
    @kosidinna_ 9 месяцев назад

    i know i'm late to this but as someone who is just getting round to backend stuff, this was very useful. Thank you

  • @cristianadejola464
    @cristianadejola464 2 года назад +2

    Currently working same subject but with SQL database. Bit complicated and stressful. But your tutorial help a lot. Thanks ones again

  • @getreadytotube
    @getreadytotube 2 месяца назад

    Thanks!

  • @ChangaSingh-y4n
    @ChangaSingh-y4n Год назад +1

    appreciate dumming down the complex concept

  • @CoryTheSimmons
    @CoryTheSimmons 11 месяцев назад

    Best tutorial I've ever seen.

  • @mayor3367
    @mayor3367 2 года назад

    Thank you so much. I had a hard time understanding how jwt does what it does. It is so much clearer now.

  • @digvijaysingh6882
    @digvijaysingh6882 Год назад

    simple and thorough. Glad you didn't use all those fancy abstractions.

  • @raprincis
    @raprincis Год назад

    Simple, helpful, and very instructive

  • @GilP-BM
    @GilP-BM 10 месяцев назад

    Love your content & input, thanks Cody!

  • @bentheafrican
    @bentheafrican 2 года назад +1

    Nice tutorial
    Looking forward to watch the next one.

  • @butwhothehellknows
    @butwhothehellknows 2 года назад

    Great job babe!!! You’re killin this!

  • @meepk633
    @meepk633 Год назад +2

    I learned today that you can use the 'public' and 'private' keywords in TypeScript constructor parameters to auto-assign them. You don't even need to list them as members. It just adds them to the instance automatically. This is completely unrelated btw. Just wanted to share.

  • @exe.m1dn1ght
    @exe.m1dn1ght Год назад

    I love this explanation ! thanks Cody !

  • @offgridvince
    @offgridvince Год назад +1

    Great video! Thx

  • @aiknowledge-n2s
    @aiknowledge-n2s 2 года назад

    Simply put together

  • @mferino1960
    @mferino1960 2 года назад

    Great video, thanks so much! I am about to build something using remix-auth (which is my first ever auth implementation) and wasn't clear on the cookie / session relationship. Most of the things I found just by browsing the web were like, the session is stored on the server and the cookie is stored on the client... thanks, that helps me not at all. This video cleared it all up and I now have a working mental model.

  • @alexvolkov529
    @alexvolkov529 2 года назад +1

    Hi! Thank you for your video! I have a question how I can store sessionId on my frontend in production?Just using the domain attribute does not work since I'm using a free hosting wich is the Public Suffix List and after all frontend and backend are hosted on different subdomains.
    Should I store sessionId on the front-side? Or is it not the case?

  • @codinginflow
    @codinginflow Год назад

    Can you tell me what's this VS Code theme? It's beautiful

    • @WebDevCody
      @WebDevCody  Год назад

      I think this is material community high contrast

    • @codinginflow
      @codinginflow Год назад

      @@WebDevCody Thank you

    • @blackpeep984
      @blackpeep984 Год назад

      shades of purple

    • @codinginflow
      @codinginflow Год назад

      @@blackpeep984 That's what I thought actually

    • @blackpeep984
      @blackpeep984 Год назад

      @@codinginflow it's my personal favorite so i knew right away what theme he's using

  • @cristianadejola464
    @cristianadejola464 2 года назад

    just subscribe to your channel. you are really helping the junior Dev. Thanks so much

  • @alexdonoaga89
    @alexdonoaga89 Год назад

    whats the extension name for copilot that you used to recive the delete cookie thing ?

  • @tljstewart
    @tljstewart Год назад

    Great content

  • @captainalpha4853
    @captainalpha4853 Год назад

    Hello, I'm using express-session package. When i log in, i see that there is a cookie in the response.
    However, when i try to make a new request to the server, I don't see the cookie in the request header.
    PS: I'm using Nuxt3 for client side.

    • @WebDevCody
      @WebDevCody  Год назад

      If you’re using axios or fetch you usually have to specify withCredentials true for all your requests

  • @velara314
    @velara314 Год назад

    If I need to authenticate across two different domains should I use Jwt or sessions?

    • @WebDevCody
      @WebDevCody  Год назад +2

      I think jwt might be easier. sessions usually use cookies which often suggest same-site policies. I'd have to research this question to be honest., but google single sign on approaches

  • @ponderatulify
    @ponderatulify 2 года назад

    How do you go about storing the session? Removing the session? How does it scale?

    • @tudor14
      @tudor14 2 года назад

      You could store the session in Redis and other user info too (but the session ID is only sent back in cookie). Removing the session you'd just find the session based on sessionId in your store/database and delete it.. And for scaling well lets just say you're on your own there...

  • @lightsinvalues9856
    @lightsinvalues9856 2 года назад

    thank you very much

  • @AnonymousPumpkin616
    @AnonymousPumpkin616 6 месяцев назад +1

    can u provide the code?

  • @sjfieksnd
    @sjfieksnd Год назад

    Cool!

  • @bamideleprecious3481
    @bamideleprecious3481 Год назад

    What plugin can I use

  • @notfadeaway6617
    @notfadeaway6617 Год назад

    nice video

  • @brianpolly-ei3nk
    @brianpolly-ei3nk Год назад

    Are you on telegram

  • @ashajanet12-a92
    @ashajanet12-a92 8 месяцев назад

    This is wayy good explanation!🫴✨

  • @AmazingTechnology-n7w
    @AmazingTechnology-n7w 3 месяца назад

    Great content