ExpressJS - Sessions

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ต.ค. 2024

ความคิดเห็น • 14

  • @Finn-jp6pn
    @Finn-jp6pn 2 ปีที่แล้ว +4

    It's inspiring how much content you've been putting out lately despite of having a full-time job. Thanks, Anson

  • @Jul05
    @Jul05 2 ปีที่แล้ว +2

    Great explanation! Thank you! :)

  • @shaharrefaelshoshany9442
    @shaharrefaelshoshany9442 2 ปีที่แล้ว +2

    thank you, amazing work

  • @carlosl-f2433
    @carlosl-f2433 ปีที่แล้ว +2

    Woah been following this excellent series so far but this one in the post and session was a whirlwind...I understood but it was the most confusing section so far...I mean trying to follow the logic

  • @jayparab2028
    @jayparab2028 ปีที่แล้ว

    I wish to delete a single session rather then using res.session.destroy() which deletes all the sessions .
    Is there a way to delete a single session ????

  • @beontrend9725
    @beontrend9725 ปีที่แล้ว +1

    how i dont understand how the cart is added in the req.sessions

    • @mauiwowie2626
      @mauiwowie2626 ปีที่แล้ว +1

      same

    • @anujbarochia3845
      @anujbarochia3845 ปีที่แล้ว +1

      me too

    • @ansonthedev
      @ansonthedev  10 หลายเดือนก่อน

      Apologies for the late reply, but figured I'd reply to this now since others have commented with the same concern.
      So when you install express sessions and use them in your app, it allows you to begin persisting "sessions" in your API server. What this means is you can take requests, and track its state by simply updating the req.session property. Each session in Express has an ID, generated by the session library. The library itself knows when its session object on request.session is modified, notice how I referenced request.session.cart and assigned it an object, and that object had the items array?
      When you modify the request.session object, usually by attaching an object to it, that tells the library to persist that session ID, so every request made by the same user will be tracked with the same session ID. If you never modify the session object at all, each time you make a request, you will see request.session.id (try logging it) will always be different.
      Try this:
      Log request.session.id, and visit the endpoint without modifying the session object at all, notice the ID, and then update request.session by attaching a property to it, such as "cart" or "points" or whatever, and then log request.session.id again each time you visit the endpoint. You will notice that it will be the same every time after modifying the session object.
      Hope this clarifies it a little bit, if not feel free to ask some more questions below.

  • @anujbarochia3845
    @anujbarochia3845 ปีที่แล้ว

    This one is too confusing. Can you please make more simplified video for the session in express. Thank you

  • @AhmedAli-jx9ie
    @AhmedAli-jx9ie ปีที่แล้ว

    could sessions be stolen that way ?

  • @AxelBertrand-gk3zk
    @AxelBertrand-gk3zk ปีที่แล้ว

    hopefully this comment make sense

  • @Jeridi
    @Jeridi ปีที่แล้ว

    😥😥 session express hard