- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the shortest function of reading a cookie by name in JavaScript?
Here’s the best way to read cookies by name in JavaScript. The following is the function −
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); } }
- Related Articles
- What is the meaning of a Persistent Cookie in PHP?
- How to set a cookie and get a cookie with JavaScript?
- What is the use of Cookie or hidden fields in JSP?
- How to return an object by parsing http cookie header in JavaScript?
- How to read a cookie using JavaScript?
- What is the purpose of a self-executing function in JavaScript?
- What is a function literal in JavaScript?
- What is the role of clearTimeout() function in JavaScript?
- What is the use of apply() function in JavaScript?
- What is the use of Math.hypot() function in JavaScript?
- What is the importance of _.initial() function in JavaScript?
- What is the use of Math.imul( ) Function in JavaScript?
- In JavaScript, what is meant by 'a function expression is always a constant value'?
- Length of shortest unsorted array in JavaScript
- What is the (function() { } )() construct in JavaScript?

Advertisements