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.  

Digital Marketing Strategies That Help Small Businesses Grow

Running a small business today means competing in a marketplace that never sleeps. Your customers are scrolling, searching, and comparing options around the clock, and if your business isn’t visible in those moments, someone else’s will be. The good news...

2026 Digital Marketing Trends Every Business Should Know

Digital marketing in the year 2026 looks nothing like it did even a couple of years ago. AI-powered search, voice assistants, and hyper-personalized content have changed how customers discover, evaluate, and choose businesses online. For local brands in Kerala,...

Best Social Media Marketing Strategies for Small Businesses in Kerala

The best social media marketing strategies for small businesses in Kerala combine local relevance, consistent content, and smart use of low-cost tools — no massive ad budget required. If you run a small business in Kerala, you already know that customers are scrolling...

How to Choose a Digital Marketing Agency in Trivandrum

Trivandrum has quietly become one of Kerala’s busiest hubs for startups, IT parks, and small businesses looking to grow online. With Technopark expanding every year and more local brands moving their operations digital, the demand for a reliable Digital...

SEO vs Google Ads: Which Is Better for Local Businesses?

Quick answer: For most local businesses, SEO is better for long-term, low-cost visibility, while Google Ads is better for immediate leads and short-term campaigns. The two aren’t rivals — they solve different problems, and the strongest local marketing plans...

Custom Web Application Development: Benefits for Growing Businesses

Introduction  Every growing business eventually hits the same wall: the generic software that worked fine at launch can no longer keep up with new processes, new customers, and new goals. This is where custom web application development becomes a turning point....

Web Design Company in Kottayam: How to Choose the Right Partner

Web Design Company in Kottayam: How to Choose the Right Partner Kottayam’s business landscape has changed fast over the last few years. Local shops, educational institutes, hospitals, spice exporters, and rubber traders that once relied purely on word of mouth...

Web Development Services in Kollam | Bytelabz Solutions

Introduction If you’re looking to build or upgrade a business website in Kollam and web development services, choosing the right development partner can significantly impact your growth. Today, your website is more than just an online presence—it is your digital...

Shopify vs WooCommerce: Which Is Right for Your Business?

Starting an online store is one of the smartest ways to grow your business, but choosing the right platform can make or break your success. When comparing Shopify vs WooCommerce, business owners often struggle to decide which platform best suits their goals, budget,...