Create Popup Cookies Consent Box in HTML CSS & JavaScript | Set Cookie JavaScript

  Рет қаралды 22,770

CodingLab

CodingLab

Күн бұрын

Пікірлер: 25
@lyubon9492
@lyubon9492 9 ай бұрын
I just needed the JavaScript part with the cookie and it works perfectly. Thank you so much for this video. Very helpful : )
@crissantanna6555
@crissantanna6555 Жыл бұрын
thank you!!!! how can I make the cookie window disappear when the person clicks reject?
@alman_harbi
@alman_harbi Жыл бұрын
Can you explain for what cookies are used for? If a user accepts it, what will be next, like we would know the user's information?
@CodingLabYT
@CodingLabYT Жыл бұрын
Cookies are small pieces of text sent to your browser by a website you visit. They help that website remember information about your visit, which can both make it easier to visit the site again and make the site more useful to you. The cookie box I have made is set only one cookie value which name is codinglab, and until that cookie expired model box will not come if you click on accept button. That cookie is for only that model box.
@benjawiBen
@benjawiBen Жыл бұрын
A good example of cookies is when you tick a box on a login page that says to remember your login for something like 30 days. Sets a cookie for 30 days and saves you having to log into that website every time. If you don't accept cookies on that website, then the remember me function won't work.
@tioem3399
@tioem3399 Жыл бұрын
Easy to follow and worked like a charm! Thank you!
@lucblouin2747
@lucblouin2747 9 ай бұрын
Very good! Thank a lot ! It works fine except how can I make the cookies window disappear when the person clicks decline? I would just like the box not to recharge when the user refuses. Please tell me if you have a solution?
@MoroccanHub
@MoroccanHub 2 ай бұрын
const cookieBox = document.querySelector(".wrapper"); const buttons = document.querySelectorAll(".button"); // Function to check if a cookie exists function getCookie(name) { const nameEQ = name + "="; const cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { let cookie = cookies[i]; while (cookie.charAt(0) === ' ') { cookie = cookie.substring(1, cookie.length); } if (cookie.indexOf(nameEQ) === 0) { return cookie.substring(nameEQ.length, cookie.length); } } return null; } const executeCodes = () => { // Check if either cookieBy or cookieDeclined exists if (getCookie('cookieBy') || getCookie('cookieDeclined')) { return; // Do nothing if either cookie exists } cookieBox.classList.add("show"); buttons.forEach((button) => { button.addEventListener("click", () => { cookieBox.classList.remove("show"); if (button.id === "acceptBtn") { // Set cookie for acceptance document.cookie = "cookieBy=codinglab; max-age=" + (60 * 60 * 24 * 30); } else if (button.id === "declineBtn") { // Set cookie for decline document.cookie = "cookieDeclined=true; max-age=" + (60 * 60 * 24 * 30); } }); }); }; // Execute function on page load window.addEventListener("load", executeCodes);
@aertic3747
@aertic3747 Жыл бұрын
Hey, is it possible to use more of your stuff, like this password strength and email validation etc. on one screen at the same time on the site? If so, how?
@social.knowledge_0
@social.knowledge_0 Жыл бұрын
Thanks you
@CodingLabYT
@CodingLabYT Жыл бұрын
Welcome
@truegoldenhands
@truegoldenhands Жыл бұрын
very good and useful ´work!
@LaurianeBL
@LaurianeBL Жыл бұрын
Hello and thanks for the tutorial but the pop up keeps showing after i refresh the page when i click on decline... do you have a solution ? Thank you :)
@lorenzolin4959
@lorenzolin4959 Жыл бұрын
Hello guys, should i use it on every page of the website? or just write it on 1 page?
@yenvi1546
@yenvi1546 Жыл бұрын
You should put it on your index or home page! So use it only once :)
@PawełMurawski
@PawełMurawski Ай бұрын
Hello, what IDE are you using here?
@CodingLabYT
@CodingLabYT Ай бұрын
Vs code editor
@mar4974
@mar4974 Жыл бұрын
what is the use of cookies?
@AjPrince7
@AjPrince7 7 ай бұрын
You don't need to signin again in a website
@AbhinavMishraA-wc3ky
@AbhinavMishraA-wc3ky Жыл бұрын
@CodingLab Hi men! Please create a video on how to create a login system using cookie 🍪! In js. Pin me!
@CodingLabYT
@CodingLabYT Жыл бұрын
Okey I will think about it.
@omorfaruk6986
@omorfaruk6986 Жыл бұрын
please give html css full website design tutorial
@CodingLabYT
@CodingLabYT Жыл бұрын
Here they are - kzbin.info/www/bejne/jqbWoGudmtB4msk kzbin.info/www/bejne/nYbbeq2laMydY8k
@enderbenderplayz5189
@enderbenderplayz5189 Жыл бұрын
source code?
@CodingLabYT
@CodingLabYT Жыл бұрын
Link is in the description.
HTML, CSS & JavaScript - How to Create a Cookie Consent Message
18:21
Web Dev Tutorials
Рет қаралды 30 М.
How to Create Popup Modal Box in HTML CSS & JavaScript
14:59
CodingLab
Рет қаралды 43 М.
Шок. Никокадо Авокадо похудел на 110 кг
00:44
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 193 МЛН
Cute
00:16
Oyuncak Avı
Рет қаралды 10 МЛН
[JS] Cookies In One Video | The Most Comprehensive Tutorial
27:22
How To Code Your Own Cookie Consent Popup with JavaScript
22:45
Code With Bubb
Рет қаралды 70 М.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 955 М.
This is why your site might need a cookie banner
5:09
Web Dev Cody
Рет қаралды 23 М.
This Cool JavaScript Effect Will Make Your Website 3D !
56:21
True Coder
Рет қаралды 1,1 МЛН
Cookie Banner Javascript - Build It Without Libraries
12:01
Monsterlessons Academy
Рет қаралды 7 М.
You Don't Need JavaScript For This - CSS ONLY Infinite Scroll
23:35
Slaying The Dragon
Рет қаралды 111 М.
How to add Cookie Notice Banner to React app 👨‍💻
6:17
Tuomo Kankaanpää
Рет қаралды 23 М.