HTML, CSS & JavaScript - How to Create a Cookie Consent Message

Sdílet
Vložit
  • čas přidán 3. 01. 2022
  • In this video, we'll show you how to create a cookie consent message and a cookie with an expiration date so the message does not show up every time the user visits the website.
    More information on how to create a cookie (very easy to follow):
    www.w3schools.com/js/js_cooki...
    Sponsor me on GitHub!
    github.com/sponsors/miguelznunez
    Follow my blog:
    / miguelznunez
    Email : mignunez@csumb.edu
    Medium : / miguelznunez
    Codepen : codepen.io/miguelznunez
    GitHub : github.com/miguelznunez

Komentáře • 31

  • @nigelhammond99
    @nigelhammond99 Před rokem

    Great video! I have been looking for a good cookie banner for some time. Well explained, well coded, simple to follow. Thank you! One more subscriber here!

  • @joebalingit
    @joebalingit Před 2 lety +3

    You've got a subscriber. Thank you so much for this helpful video. Keep 'em coming...

  • @mihaelabalaceanu7905
    @mihaelabalaceanu7905 Před 2 lety +2

    Very well explained! Thx so much, it was so helpful!

  • @kageyoshi3656
    @kageyoshi3656 Před 3 měsíci

    Easy to follow, gets the job done, works flawlessly -> Subscribed! + Liked! + Shared!

  • @EinDummie
    @EinDummie Před 3 měsíci

    Hey Sir, your Tutorial helped me alot, thank you and keep it up.

  • @_661.
    @_661. Před 8 měsíci

    Nice bro❤

  • @MillerHighLifez420
    @MillerHighLifez420 Před 2 lety

    Thanks!

  • @loonatik_official
    @loonatik_official Před rokem

    thank you!

  • @chupacabrapr
    @chupacabrapr Před rokem

    Thanks for the video very helpful. Im having an issue, i set the expiration date and create the cookie. The exp date shows fine, but when I refresh my browser the exp date changes to “session”. Any idea why? Thanks

  • @agritech802
    @agritech802 Před 6 měsíci

    Great video, what editor are you using?

  • @rjapade3062
    @rjapade3062 Před 11 měsíci

    Can u please help me , uncaught references error: data is not defined at setCookie ??

  • @yoskokleng3658
    @yoskokleng3658 Před 3 měsíci

    why we need it (click to store cookie)? i saw many website have done this. please make a video of benefit of it?

  • @jad3nk674
    @jad3nk674 Před 4 měsíci

    i have a question i never saw in my cookie menu with the inspect mode one that says cookie true so now i cant see the cookie and i have to show it to my teacher

  • @jfpicard1
    @jfpicard1 Před 10 měsíci

    Question here ... To be 100% compliant .. should this "consent" be stored somewhere?

  • @durangodave
    @durangodave Před 8 měsíci

    dont we need to secure the cooke?

  • @xchen6190
    @xchen6190 Před 8 měsíci

    Thanks! how to give the user option to reject the cookie?

    • @agritech802
      @agritech802 Před 6 měsíci

      Create a button called reject and store them value reject in the cookie

  • @alexandermarcondesjunior1608

    i getting this error :
    default.js:34 Uncaught TypeError: Cannot set properties of undefined (setting 'display')
    at cookieMessage
    someone can help me?

    • @codefoxx
      @codefoxx  Před 2 lety

      It cannot find the element you are trying to add the "display" property to. Perhaps you forgot to create it, mispelled it, did not add the appropriate id, etc. Basically you are missing something. Please rewatch the tutorial

  • @AashutoshBansal
    @AashutoshBansal Před 2 lety +2

    Bro can u remake video of grocery-list with localStorage, As I'm not able to do so. Please Please Please Please

    • @codefoxx
      @codefoxx  Před 2 lety +3

      I can do that but I actually don't recommend beginners using local storage beyond 1 or 2 basic projects because that's not how data is stored in a real application. What you wanna learn is how to store it in a database like mySQL or MongoDB, which requires knowledge of Node.js or a framework like Django or Spring Boot.

    • @AashutoshBansal
      @AashutoshBansal Před 2 lety +1

      @@codefoxx ok 👍

  • @bilalbehar8533
    @bilalbehar8533 Před 2 lety +1

    can you please help me, i followed every step , but the paragraphe inside the cookies container is empty

    • @codefoxx
      @codefoxx  Před 2 lety +1

      Please recheck the code you must be missing something

    • @bilalbehar8533
      @bilalbehar8533 Před 2 lety

      @@codefoxx i tried to follow many other videos . But still have the same problem
      Thank you anyways

    • @aruzhannurmanova3696
      @aruzhannurmanova3696 Před 2 lety +1

      @@codefoxx Hi! I have the same issue. maybe there are some missing parts in the code on this video? 'cause I rechecked each part and I am sure that I wrote it correctly.

    • @codefoxx
      @codefoxx  Před 2 lety

      @@aruzhannurmanova3696 can you share your code with me? Maybe you can share the Github repository

    • @bilalbehar8533
      @bilalbehar8533 Před 2 lety

      @@codefoxx its working thanks

  • @bilalbehar8533
    @bilalbehar8533 Před 2 lety +3

    can someone pls paste the css file here

    • @adarshc7737
      @adarshc7737 Před 10 měsíci

      *{
      padding: 0;
      margin: 0;
      }
      body{
      font-size: 1rem;
      }
      .container{
      width:1600px;
      margin: auto;
      }
      .subcontainer{
      width: 85%;
      margin: auto;
      }
      #cookies{
      width: 100%;
      position: fixed;
      bottom: 0;
      color: aliceblue;
      background-color: rgba(0, 0, 0, 0.311);
      z-index: 1;
      display: none;
      }
      .cookies{
      min-height: 70px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 10px;
      }
      .cookies .a{
      color: yellow;
      text-decoration: none;
      font-weight: 500;
      }
      #cookies-btn{
      border-radius: 5px;
      padding: 6px 8px 6px 8px;
      font-size: 1rem;
      font-family: inherit;
      cursor: pointer;
      border: 1px solid white;
      background-color: black;
      color: white;
      }
      @media(max-width:1600px){
      .container{
      width: 100%;
      }
      }
      @media(max-width:1024px){
      .cookies{
      padding: 10px 0;
      }
      }