
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to list down all the cookies by name using JavaScript?
To lists down all the cookies by name, use the cookies pairs in an array. After that, you need to get the key value pair out of this array.
Example
You can try to run the following code to list all the cookies
<html> <head> <script> <!-- function ReadCookie() { var allcookies = document.cookie; document.write ("All Cookies : " + allcookies ); // Get all the cookies pairs in an array cookiearray = allcookies.split(';'); // Now take key value pair out of this array for(var i = 0; i < cookiearray.length; i++) { name = cookiearray[i].split('=')[0]; value = cookiearray[i].split('=')[1]; document.write ("Key is : " + name + " and Value is : " + value); } } //--> </script> </head> <body> <form name = "myform" action = ""> <p> click the following button and see the result: </p> <input type = "button" value = "Get Cookie" onclick = "ReadCookie()"/> </form> </body> </html>
- Related Articles
- How to list down all the files alphabetically using Python?
- How can I list all cookies on the current page with JavaScript?
- How to clear all cookies with JavaScript?
- How to get all options in a drop-down list by Selenium WebDriver using C#?
- How to list down all the files available in a directory using C#?
- List down the name of the Web drivers supported by Selenium.
- How to list down all the running queries in MySQL?
- How can I delete all cookies with JavaScript?
- How to create domain-based cookies using JavaScript?
- How to access cookies using document object in JavaScript?
- How to list down all the plug-in installed in your browser?
- How to list down all the available commands and aliases on Linux?
- How to show name/value pairs of cookies in a document with JavaScript?
- How to display all items in the list in the drop down in Selenium?
- How to create cookies in JavaScript?

Advertisements