• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in JavaScript by
How can you use JavaScript to read a cookie?

1 Answer

0 votes

You can read a cookie as simply as creating a cookie in JavaScript as it is actually the value of the document.cookie object. If you want to access that specific cookie, you can use this string any time. 

By using the document.cookie string, you can keep a list of name – value pairs which are separated by semicolons, where the name is actually the name of a cookie and the value is the string value.

You can also make use of strings’ split() function to break the string into values and keys.

Related questions

0 votes
asked Oct 19, 2019 in JavaScript by SakshiSharma
+1 vote
asked Dec 4, 2019 in JavaScript by SakshiSharma