SameSite Cookie Attribute Explained by Example (Strict, Lax, None & No SameSite)

Поділитися
Вставка
  • Опубліковано 10 січ 2025

КОМЕНТАРІ • 125

  • @hnasr
    @hnasr  11 місяців тому +5

    google has started deprecating Third party cookies (samesite=none essentially) in 2024. You might be among the 1% experiment. that might explain why it's working anymore. I wrote about this here and left resources too.
    medium.com/@hnasr/google-is-deprecating-3rd-party-cookies-d987603607a7

    • @konqestiare
      @konqestiare 10 місяців тому

      Yeah, I just noticed. I have a web application in nextjs and django. It's working fine on Firefox and GNOME Web (a.k.a. Safari lol), but it's authentication stopped working on Chromium (cookies aren't being set). Thanks man!

  • @williambattle5068
    @williambattle5068 2 роки тому +9

    Thanks a bunch - just what I needed! I found the explanation in a lot of places but the visuals really clarified it for me.

  • @ali-wz6nz
    @ali-wz6nz 12 днів тому

    00:04 - Understanding SameSite cookie attributes and their impact on web functionality.
    01:47 - Explains SameSite cookie behavior with strict settings during login.
    03:32 - SameSite Strict attribute prevents cookies from being sent on same-site requests.
    05:18 - Understanding top-level navigation issues with SameSite cookie attributes.
    06:57 - Understanding SameSite cookie behavior with examples of Lax and None attributes.
    08:53 - SameSite=None allows cross-site requests, posing security risks like CSRF.
    10:44 - Chrome 80 changes how cookies are sent without SameSite attribute.
    12:29 - SameSite cookie settings impact resource sharing and authentication.

  • @gagangupta1255
    @gagangupta1255 4 роки тому +6

    Hussein go bless for explaining this feature so nicely. Even after reading/watching 10's of video - the concept was not clear. Seriously you did a great job explaining it so easily with a practical example

    • @hnasr
      @hnasr  4 роки тому +2

      Gagan Gupta Hi Gogan! I am happy the video helped 😊 have a great day

  • @ashish_gupta307
    @ashish_gupta307 2 роки тому

    I checked for this topic on many channels but got it clear from here.....thanks hussein.

  • @vicky2118
    @vicky2118 4 роки тому +8

    Finally I understood this concept... Thanks for this great explanation 👍

    • @hnasr
      @hnasr  4 роки тому

      ❤️

  • @JiyOnFire-vg4xx
    @JiyOnFire-vg4xx Рік тому

    Thank u sooo much sir. I was searching for it the whole day but I didn't understand before u explained it. It's really precious

  • @hnasr
    @hnasr  4 роки тому +4

    Still Having trouble with SameSite? Rowan from Google is willing to help one-on-one check his twitter twitter.com/rowan_m/status/1280821505757044736?s=21

    • @RowanMerewood
      @RowanMerewood 4 роки тому

      Thanks, Hussein! Definitely happy to chat with people. Hearing about the issues people are having helps me in turn improve the documentation and samples too.

    • @FLUTTERMAD
      @FLUTTERMAD 4 роки тому

      What if cookies are available for specified domain or path, but SameSite is Lax/None?

    • @RowanMerewood
      @RowanMerewood 4 роки тому

      @@FLUTTERMAD Domain and Path specify requirements for the request with the cookie, SameSite specifies a requirement for the *context* of the request. e.g. Domain can control if the cookies goes to sub1.example.com or sub2.example.com while SameSite specifies if the cookie should go to sub1.example.com when the request comes from another site, like google.com.

  • @iamboltzmann412
    @iamboltzmann412 7 місяців тому +1

    Thanks a lot brother, I recently made a new website and the front end and backend are hosted on two different services, I was breaking my head over why the browser was not sending cookies. This explains why. I guess I have to use some other way, since google deprecated cross site cookies

  • @samnayakawadi
    @samnayakawadi Рік тому

    Subscribed. ChatGPT failed to explain this concept. Thanks dude.

  • @namangupta1817
    @namangupta1817 4 роки тому +4

    That excitement level for domain name 😂😂😂😂😂

  • @justcoding2491
    @justcoding2491 3 роки тому +3

    Very well explained in detail with good example ❤️👍🏻

  • @thoriq_aulia
    @thoriq_aulia 2 роки тому

    Finally I understand about sameSite parameter, Thx man you save the day

  • @_dinesh
    @_dinesh 4 роки тому +10

    This is how you explain things!!!!! Thank you so much 🙏🙏🙏. Google Chrome team should use this as their office video because their video is just a crap.

  • @AUBCodeII
    @AUBCodeII Рік тому +1

    Thanks for making a clear explanation of SameSite!

  • @mrstatler
    @mrstatler 9 місяців тому +1

    Still don't know why there's cookie for the second site referencing image from the first one when both are open in chrome. But when one is open in chrome & 2nd in fox it doesn't seem to work.

  • @rohandvivedi
    @rohandvivedi 4 роки тому +1

    This is one of the best illustration for the usage of samesite.
    thanks

    • @hnasr
      @hnasr  4 роки тому

      Rohan Dvivedi thanks Rohan

  • @shadmanfatin777
    @shadmanfatin777 2 роки тому +1

    Amazing explanation. Thank you Nasser sir.

  • @shuaiqingluo4400
    @shuaiqingluo4400 11 місяців тому

    this is an excellent video explaining the same-site policy of cookies!

  • @RotemNeshaGalea
    @RotemNeshaGalea Рік тому

    thanks god! I learned this in collage that i paid a lot of money. and now it the first time i really understand this issu . thank you

  • @Ravi.Benedetti
    @Ravi.Benedetti 4 роки тому +2

    Thank you sir. You are a gentleman and a scholar.

  • @thalyssonleite1479
    @thalyssonleite1479 2 роки тому +1

    Thank you! It's very clear now what that cookie with sameSite do

    • @isbemorph
      @isbemorph Рік тому

      Node would throw a typo. But samesite or SameSite works fine..

  • @MrMonishSoni
    @MrMonishSoni 2 роки тому

    Best video for samesite Attribute (Cookies)

  • @waelhabbalLMS
    @waelhabbalLMS Місяць тому

    The perfect explain, GOOD JOB and thank you.

  • @justme8code
    @justme8code 12 днів тому

    Yeah, it really gets weird with authentication, been having issues lately with my spring boot and nextjs , but thanks I understand them now

  • @g-luu
    @g-luu 4 роки тому +5

    Superior content as always.

    • @hnasr
      @hnasr  4 роки тому

      Thanks Bryan !

  • @matthewespindola3694
    @matthewespindola3694 3 роки тому

    Wow, you are great man. What a perfect explanation. Thanks!

  • @aliyevruslan936
    @aliyevruslan936 Рік тому

    @hnasr The server setup things you mentioned at ~ 1.56m, which of your video teaches such server setups? You have many videos

  • @PauloSá-h5m
    @PauloSá-h5m Рік тому

    Thank you for the information. It was really useful.

  • @nitinverma7419
    @nitinverma7419 7 місяців тому

    Thanks brother, You saved a lot of time for me :)

  • @ExtraTurtle
    @ExtraTurtle Рік тому

    what makes the image display only with the cookie? I thought the cookie being strict means it lets you access the cookie itself from the same site only. where is the code for the img, and how do you make it follow the cookie settings?

  • @tsdineshjai8565
    @tsdineshjai8565 5 місяців тому

    @hnasr usually when you visit a site, the server will send the cookie to the browser right. But in the video, you have mentioned several times that "Browser" will not send the cookie if it's cross site. Can you explain on this please ?

  • @supa1009
    @supa1009 4 роки тому +4

    haha thanks for the tutorial and positive energy :D

  • @roman_mf
    @roman_mf Рік тому

    Beautifully visualized!

  • @kumaravelrajan
    @kumaravelrajan Рік тому

    Excellent presentation. Thank you 😁

  • @pedrosampaio8293
    @pedrosampaio8293 4 роки тому +1

    Brilliant explanation!!!

  • @alexeicodes
    @alexeicodes 2 роки тому

    The best explanation i love it so much

  • @user-mu5il5in3g
    @user-mu5il5in3g Рік тому

    Amazing explaination !! thanks a ton!!!

  • @DevAmirull
    @DevAmirull Рік тому

    What a perfect explanation. Thanks.

  • @nishantdalvi9470
    @nishantdalvi9470 Рік тому

    Please some one clear my doubt, The image of one domain is getting loaded on another domain if the attribute Same-site has the value None right but what about the SOP (Same Origin Policy) ain't it gonna block the responses from cross domain ?

  • @yaseralamoodi8314
    @yaseralamoodi8314 4 роки тому +3

    Thank brother I really appreciate your work and get a lot of experience from you, my question is isn't cookies shloud just work for the same domain?، I mean it shouldn't be exists if you open a new tab for another domain

    • @hnasr
      @hnasr  4 роки тому +4

      Correct ! Cookie are domain specific, but 3rd party cookies were invented for tracking purposes

  • @raminiskandarov
    @raminiskandarov 3 роки тому

    Thanks for this perfect explanation. just perfect

  • @manikandankm3974
    @manikandankm3974 3 роки тому

    What if we want to make any request from Domain A through api call to fetch information from Domain B when same site = Strict ? what is the way to achieve the same

  • @channaly2772
    @channaly2772 Рік тому

    Great example! Many thanks

  • @ebaduddin2624
    @ebaduddin2624 3 роки тому +1

    beautifully explained..thanks

  • @smartaquarius2021
    @smartaquarius2021 3 роки тому

    Is it possible to access samesite lax cookie in case api is integrated with openid connect for single sign on. Currently why they are inaccessible because oidc url auto redirects to my api and at that time api try to read the cookies at server side. Any suggestions on this please??

  • @goatslayer5957
    @goatslayer5957 11 місяців тому

    Is it possible they have patched this? I can't get cross-site cookies working! I used your express file and uploaded to render. Then I also made a GitHub page with an image src pointing to the render https link, but the cookie is never sent!!

  • @MrJohn360
    @MrJohn360 3 роки тому

    Great explanation, thanks for sharing.

  • @ismaillachhab741
    @ismaillachhab741 3 роки тому

    Good explanation , Thank you so much

  • @ektanawle1088
    @ektanawle1088 4 роки тому

    Thanks for the explanation Hussein. I got one question ..if someone is using my site login page on their website then who would set the samesite : none
    (I as a site owner or the one who is using our login page). Could you please help me find this.
    I have set in my code samesite:none but when I am trying to login through their site it still showing samesite:Lax while when I login through mysite changes are reflecting as none

  • @ManiKandan-vo2qr
    @ManiKandan-vo2qr 4 роки тому

    Hi , I have a small doubt . What would be the case when it is not Secure . Please let me know the behavior when both are communicating with HTTP

  • @AbhiSeSeekho
    @AbhiSeSeekho 3 роки тому

    If same site attribute is set to lax the browser is sending the cookie then how it prevent csrf?

  • @ashherali7613
    @ashherali7613 Рік тому

    nice explanation keep it up dude

  • @techwithameer
    @techwithameer 4 роки тому

    why redirection to a site not working when same site is lax but the request from another site is 'post'?
    will this works only for 'GET'?
    Iam getting issue when my my site is redirected from a payment gateway. They are redirecting using a POST request.

    • @hnasr
      @hnasr  4 роки тому +1

      AMR K Post requests won’t send lax cookies to cross site, there is however an exception if those lax cookies are created within two minutes
      A SameSite Cookie Exception was made to avoid Redirect Loop in Single Sign-On (SSO) Let us Discuss
      ua-cam.com/video/4QiD8cvzCN0/v-deo.html

  • @mishapatel3119
    @mishapatel3119 3 роки тому

    How Can we access the cookies in request header with httpOnly ?? Plz help i m in trouble to get these cookies in all request header

  • @morganfree100
    @morganfree100 2 роки тому

    @hussein Nasser: Does this applies to webscoket?

  • @Jamie-pq9gn
    @Jamie-pq9gn 3 роки тому

    Hi Nasser, I have a question, How is https in the video implemented? No certificate is imported in the source code.

    • @hnasr
      @hnasr  3 роки тому

      Hey , I skipped that part since I explained it on other videos ua-cam.com/video/b35Dcz91ItE/v-deo.html

    • @Jamie-pq9gn
      @Jamie-pq9gn 3 роки тому

      @@hnasr thank you very much 🙏

  • @dmbarry86
    @dmbarry86 4 роки тому

    Brilliant explanation, thanks.

    • @hnasr
      @hnasr  4 роки тому

      Glad it was helpful!

  • @vladislavgerginov748
    @vladislavgerginov748 Рік тому

    Thanks for the great example. But how do you set these properties on a site with a drag-and-drop site builder is the real question?

    • @urssaf343
      @urssaf343 Рік тому

      This is done on the backend. Drag and drop stuff is just the page that is being sent to the user.

    • @vladislavgerginov748
      @vladislavgerginov748 Рік тому

      @@urssaf343 agree to that. A tutorial about how it's done on the back end will be very appreciated. Or it's too much to ask?!

    • @urssaf343
      @urssaf343 Рік тому +1

      @@vladislavgerginov748 Lookup course from Mosh Hamedani: restful apis with express.

  • @gokusupersayiandbgt
    @gokusupersayiandbgt 4 роки тому

    Hi, does thed same site attribute provide protection on all browsers like IE, Firefox or just chrome latest

    • @hnasr
      @hnasr  4 роки тому

      nvn dnt Correct all browsers now supports it except for IE developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite

  • @petruconiuc4618
    @petruconiuc4618 4 роки тому +1

    Very impressive explanation, but how do you set a cookie with a domain other than your own?

    • @hnasr
      @hnasr  4 роки тому

      You can’t that is the security aspect of cookies. They are set by the owner of the domain
      You can set the cookie from the client side with Javascript document.cookie but still you would have injected some code to do so in someone else’s domain

  • @techwithameer
    @techwithameer 4 роки тому

    I need same site mode strict but then my redirection from a payment site is not working.
    Is there any solution to keep it working without changing same site strict mode?

    • @hnasr
      @hnasr  4 роки тому +1

      I think its safe to use lax for your use case since you are redirecting. I don’t know if you can use strict and still send the cookies while redirecting..

  • @QuranKareem22
    @QuranKareem22 Рік тому

    good explanation thanks!

  • @thalyssonleite1479
    @thalyssonleite1479 2 роки тому

    Greetings from Brazil!

  • @surajbhushanpandey2882
    @surajbhushanpandey2882 2 роки тому

    Nice work @ Hussein

  • @iCydiaHelper19
    @iCydiaHelper19 4 роки тому

    I am getting HTTP error 405, any advices?

  • @desarrolladorrapido8767
    @desarrolladorrapido8767 4 роки тому

    Excellent example with IMG and A, a question, How about IFRAME and AJAX?

    • @hnasr
      @hnasr  4 роки тому +1

      Desarrollador Rápido both are very similar to IMG. Thanks!

    • @desarrolladorrapido8767
      @desarrolladorrapido8767 4 роки тому

      I see, thank you.

    • @glenndwiyatcita1663
      @glenndwiyatcita1663 4 роки тому

      @@hnasr Hmm but according to owasp.org/www-community/attacks/csrf#other-http-methods, JavaScript is subject to same-origin policy. ...which means if AJAX is used to make a request from your other origin (hnasr.github.io), it won't be executed in the first place.

  • @nikhil_arora
    @nikhil_arora 2 роки тому

    too good. thanks for this video!

  • @quangaonguyen7898
    @quangaonguyen7898 3 роки тому

    How do we set samesite = none?

  • @allanimeworld2898
    @allanimeworld2898 3 роки тому +1

    Sir please make a video on how to access cookie from other website.
    Means how cross-site is done.
    🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

  • @birdofhermes6152
    @birdofhermes6152 4 роки тому

    Thanks for the explanation

  • @alimahboub4163
    @alimahboub4163 3 роки тому

    That's the best explanation ever! Well done my friend. Keep it going

  • @singh.karanbir
    @singh.karanbir 4 роки тому

    This is nice explanation
    But there is a room for explanation around the cookies being set while calling login api

  • @MedoMedo-op3em
    @MedoMedo-op3em 3 роки тому +1

    BRILLIANT !!

  • @MaheshBh6
    @MaheshBh6 3 роки тому

    Stating the obvious here but this is a HTTPS only feature, so the flags won't work in any dev environments that don't have https configured

  • @techwithameer
    @techwithameer 4 роки тому +1

    Thanks for this bro...

  • @alvin_lal
    @alvin_lal 3 роки тому

    Thanks sir, very helpful

  • @nileshmonde4707
    @nileshmonde4707 Рік тому

    Thanks for the video

  • @mursalrabb6093
    @mursalrabb6093 3 роки тому

    same-site = None useless? i'd say no. Its pretty useful during development phase when your frontend and backend are running at different ports

  • @alii4334
    @alii4334 3 роки тому

    you can keep the devtools open!

  • @bojandanon2037
    @bojandanon2037 2 роки тому

    Very nice 👍

  • @saeedp92
    @saeedp92 9 місяців тому

    excellent thank you

  • @jyotirmoymaschatak5960
    @jyotirmoymaschatak5960 Рік тому

    Thanks Boss!

  • @shubham_srt
    @shubham_srt Рік тому

    Thanks :)

  • @bum7006
    @bum7006 3 роки тому +1

    Thanks

  • @utkuaslan701
    @utkuaslan701 4 роки тому

    thanks!!

  • @ca7986
    @ca7986 4 роки тому

    ❤️

  • @nguyenluat-gj8vx
    @nguyenluat-gj8vx 9 місяців тому

    thanks

  • @lawfirm3843
    @lawfirm3843 3 роки тому

    haha. master

  • @omarislearning3329
    @omarislearning3329 3 роки тому

    cmd+/

  • @christymathew9035
    @christymathew9035 2 роки тому

    SUBSCRIBER ++