Sessions in Node #1 | Authentication in Node.js with Express and sessions | Sessions explained

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

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

  • @josephchris8629
    @josephchris8629 9 месяцев назад +2

    I can not be grateful enough. This is my first comment ever on RUclips. You are indeed a great Teacher!

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

    Man, Im still here wondering why you dont have 1Mi + subs... thats insane. Great content, of course liked + subbed

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

      Thanks for the sub!

  • @adamgontiersa78
    @adamgontiersa78 2 года назад +3

    CRIMINALLY UNDERRATED

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

    This is a gem! Thank you for this video!

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

    Excellent video. I have watched a lot of videos on this topic but this one actually helped the topic click in my head.

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

      Glad you enjoyed it!

  • @n4vyblueyes377
    @n4vyblueyes377 4 года назад +1

    I appreciate the walk through with the diagram!!!

    • @jgoebel
      @jgoebel  4 года назад

      Thanks, I'm glad you like it 👍

  • @prajwalsiwakoti9866
    @prajwalsiwakoti9866 3 месяца назад

    Well explained, Thank you!

    • @jgoebel
      @jgoebel  Месяц назад

      Glad you liked it!

  • @emyboybeats4330
    @emyboybeats4330 3 года назад +1

    Your just too good Man

  • @kinder-krish
    @kinder-krish 4 месяца назад

    I have one doubt while making requst, Browser share the session id to server , does it also share the jwt to token in cookies
    ? Thankyou sooo much for your valuable content💖

  • @juranovium6808
    @juranovium6808 4 года назад

    No JWT, Passport or Auth0. Love it!

    • @jgoebel
      @jgoebel  4 года назад +1

      Thanks, passport would be overkill in that case. Although it might be useful for OAuth 2 and so on. And JWTs don't make good session tokens 😁

  • @Niamat-w9s
    @Niamat-w9s 4 года назад

    awesome explanation.
    I learnt a lot from this session series.
    thank you so much.

    • @jgoebel
      @jgoebel  4 года назад

      thanks, glad to hear that 👍

  • @oneplus1861
    @oneplus1861 4 года назад

    Crystal clear!

  • @ShivamSharma-kx5lj
    @ShivamSharma-kx5lj 4 года назад

    amazing description. Love that flow diagram.

    • @jgoebel
      @jgoebel  4 года назад +1

      Glad you like it 👍

  • @alexandrebalay6295
    @alexandrebalay6295 4 года назад

    I am excited to start this new playlist !
    By the way, your sound is a bit low compared to other videos I watch. This is not a big issue but I noticed that I always increase the volume on your channel, just FYI ;)

    • @jgoebel
      @jgoebel  4 года назад +2

      I'm glad you like it 👍
      I have just re-rendered the videos that are not out yet and bumped up the volume. Unfortunately I cannot change a video once it is published. So starting at part 6 the audio will be louder. Until then I think you will need to turn the volume a little. Sry. for that, still trying to figure out the best technical setup.

    • @jgoebel
      @jgoebel  4 года назад +1

      I just released part 6:
      ruclips.net/video/i6190xVJMh8/видео.html
      Audio should be better there

    • @alexandrebalay6295
      @alexandrebalay6295 4 года назад

      @@jgoebel Sound is perfect now, thanks!

  • @shamilmammadov8246
    @shamilmammadov8246 4 года назад

    Thanks a lot. Perfect explanation

    • @jgoebel
      @jgoebel  4 года назад

      thx. I'm glad it was helpful!

  • @digvijayyamagekar4300
    @digvijayyamagekar4300 3 года назад

    thank you very much

    • @jgoebel
      @jgoebel  3 года назад +1

      You are welcome

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

    Hey if we dont want to send the sessionID to client side, is there any way for it.

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

      we already send the session id to client in the cookie. However, we deliberately set the cookie to HttpOnly so that no JS can access it. The browser will send it along automatically. If no JS on the client side can access it, then we have a smaller attack surface

  • @zillionvfx4786
    @zillionvfx4786 3 года назад

    your explanation is very good brother.. everything is very clear... I ve one little question.. so you set cookie duration as 30 mins... so after expires that user has to re enter credentials and re login while user online in the system... so how to persist the session if i want to do so. for feature like "remember me" option. Thank you so much for sharing this awesome knowledge..

    • @jgoebel
      @jgoebel  3 года назад +1

      Hi Zillion, the user gets logged out after 30min of inactivity. I.e. if you are inactive for 29 minutes but then you make an action so that your session is modified, then you get another 30min on the clock.
      The remember-me option would be implemented by keeping the session alive for longer

    • @zillionvfx4786
      @zillionvfx4786 3 года назад

      @@jgoebel Thanks buddy. So if I set one month or more as expiry, is it bad for security?

    • @jgoebel
      @jgoebel  3 года назад +1

      @@zillionvfx4786 depends on what other security measurements you've taken and what type of application you are building and also on the total amount of users. If you want to keep them logged in for that long, you could also think about using JWTs in local storage / cookie. But I would only do this if you do not need to log someone out from the server side and if you are not working in a highly security-constrained environment (which is what I would assume otherwise you would probably not offer the stay logged in functionality). If you do this, you will also need good XSS protection (content security policy) and proper CSRF protection.

    • @zillionvfx4786
      @zillionvfx4786 3 года назад

      @@jgoebel for even that question you provide me a huge explanation. For that I hit the bell icon also.. you are a goat buddy... Add more cool stuff and thanks a ton again buddy... ❤❤❤

    • @jgoebel
      @jgoebel  3 года назад

      @@zillionvfx4786 thx 👍

  • @thesingularity3566
    @thesingularity3566 3 года назад

    What's the best strategy to implement logging user out?

    • @jgoebel
      @jgoebel  3 года назад

      you can call req.session.destroy. This will delete the server side session and thus log out the user immediately: github.com/expressjs/session#sessiondestroycallback

  • @AbdelhameedG
    @AbdelhameedG 4 года назад

    That's good, thanks.

  • @fooked1
    @fooked1 3 года назад

    Would be great if you could do one of these with passport js

    • @jgoebel
      @jgoebel  3 года назад

      will add that to my list of potential topics 👍

  • @mel7im19911
    @mel7im19911 4 года назад

    Great Effort.
    I appreciate it you answer the following question:
    Will the session be created for any new request (new customer) if there is no login required (for example : a website which is not required any login, then will the session be created for each user, if yes, then what the benefits I can get from the session). if no, then why not ?

    • @jgoebel
      @jgoebel  4 года назад +1

      You can control this behaviour with the saveUninitialized setting. If it is set to true, then the server would create a session for every new user that does not have a session yet even if no data is stored inside of the session. That would also mean that if you plug in the session middleware and never use it (i.e. you never store something inside of the session), it would generate empty sessions for your users. You can read about this property here: github.com/expressjs/session#saveuninitialized
      Typically you probably want to avoid doing this because it would be a waste of resources. So if you set saveUnitialized to false (like we do in the tutorial), we only create a session, push it to the session store (Redis) and set a cookie if we are actually saving data inside of it.

  • @starterdev
    @starterdev 4 года назад +1

    The sound is weak for me

    • @jgoebel
      @jgoebel  4 года назад +1

      Sry. for that, I'm currently trying to figure out the best setup. I re-rendered all the videos that are not out. Since I cannot change videos that are already published, it could be that the audio until part 5 is a little bit low. But from part 6 to end it should be good 👍

    • @jgoebel
      @jgoebel  4 года назад

      Btw, I just released part 6 - audio should be better there: ruclips.net/video/i6190xVJMh8/видео.html

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

    My speaker is broken

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

    Hello

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

    after knowing jwt is not that kinda secure enough: 💀💀