WhatsApp
call

Get all cookies with Javascript

Dec 18, 2017 2 Minutes Read Bytelabz
Its very common that we all still use HTTP or HTTPS cookies for storing various data on visitor’s browser. But in HTML5 , you can use local storing various data . I’m talking about the old school for getting all the cookies using the Javascript . Here as we still have old browsers to take care of the cookies. The jQuery Cookie plugin (http://plugins.jquery.com/project/Cookie) is useful for getting the value of cookies when you already know the name of the cookies you want to query from the browser, but provides no way to get a list of all the cookies that are set already. The following Javascript function loads them all into an associative array with the cookie name as the index and the cookie value as the value: function get_cookies_array() { var cookies = { }; if (document.cookie && document.cookie != ”) { var split = document.cookie.split(‘;’); for (var i = 0; i < split.length; i++) { var name_value = split[i].split(“=”); name_value[0] = name_value[0].replace(/^ /, ”); cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]); } } return cookies; } var cookies = get_cookies_array(); for(var name in cookies) { console.log( name + ” : ” + cookies[name] + “ ” ); } You could then get the cookies and write them out into the document like so: var cookies = get_cookies_array(); for(var name in cookies) { document.write( name + ” : ” + cookies[name] + “<br />” ); } You can access cookie information in javascript using document.cookie function, but you will only be able to read the cookies that are on the same domain that the script is being run.  

Complete Guide to Digital Marketing Strategy 2026

Let’s be honest — digital marketing in 2026 feels a little overwhelming. There are ads everywhere. Social media algorithms keep changing. AI tools are popping up every other week. And every agency you talk to tells you their service is the one thing your...

Web Design & SEO Services in Kerala

Discover the Leading Web Design & SEO Services in Kerala In 2026, Kerala’s digital marketplace has grown more competitive than at any point in the last decade. Businesses that invested in professional web design and SEO three years ago are now seeing...

How to Optimize Your Website for Search Engines in 2026

In 2026, businesses must continuously optimize website for search engines visibility to stay ahead in the competitive digital world. Search engines are smarter than ever, focusing on user experience, helpful content, website speed, mobile responsiveness, and AI-driven...

Best Web Design Packages for Small Businesses in Trivandrum

Trivandrum’s small business landscape is more competitive online than ever. In 17+ years working with businesses across across the city all competing for the same Google searches — we have seen what separates websites that rank and convert from those that...

What to Look for in a Professional Web Development Partner

For businesses in Trivandrum competing for online customers — whether you’re in IT, healthcare, or retail — your website is often the first and only impression you get. Here is what separates agencies that deliver measurable results from those that deliver only...

How to choose a reliable web design company in Kottayam?

Introduction In today’s digital-first world, your website is often the first impression your business makes. Whether you run a small local business or a growing enterprise in Kottayam, having a professionally designed website is no longer optional—it’s essential....

What AI Sees When It Visits Your Website & How to Fix It?

Have you ever wondered what AI sees when it visits your website? Many website owners focus on design, colors, and user experience—but search engines and AI systems don’t see your website the same way humans do. Understanding what AI sees when it visits your website is...