The Complete WebDeveloper (42 Blogs) Become a Certified Professional

Setting Cookies in HTML: All you Need to Know About

Published on Oct 21,2019 84 Views

MI-new-launch

myMock Interview Service for Real Tech Jobs

myMock-mobile-banner-bg

myMock Interview Service for Real Tech Jobs

  • Mock interview in latest tech domains i.e JAVA, AI, DEVOPS,etc
  • Get interviewed by leading tech experts
  • Real time assessment report and video recording

Cookies are a good way to make use of your previous data. In this article we will understand about Cookies in HTML in the following order:

 

What are Cookies in HTML?

These are the data stored in small text files on the computer. The cookies were invented to remember the information of the user. Because when a web server sends a website to the browser and if it by any external factors shuts down then the server forgets everything about the user.

Cookies-in-HTML

To overcome these cookies were created to store this information.

 

 

Working of Cookies

When a user visits a web page his name will be stored in the cookie. If the same user visits the web page again then the web page remembers the user and provides related feeds related to the previously searched items. These cookies are exchanged between web browsers and web servers to keep track of different information based on the need of the web application. Cookies are saved in name-value pairs like:

username = Edureka don

When a browser requests a web page from a server, cookies belonging to the page are added to the request. This way the server gets the necessary data to “remember” information about users.

The <meta> tag can be used to store cookies on this side of the client. These cookies are used by the server to keep track of the site visitor. Hence there will always be a pop up on some websites which ask you to its policy of using cookies.

 

Cookies in HTML: Code

Example for redirecting current page to another page after 5 seconds:

<!DOCTYPE html>
<html>
		<head>
			<title>Meta tags </title>
			<meta name="keywords" content="HTML, Meta Tags, Metadata" />
			<meta name="description" content="Learning about Meta Tags." />
			<meta name="revised" content="tutorialpoint, 24/8/2019" />
			<meta http-equiv="cookie" content="useri8d=xyz; expires=sunday, 24-Sep-19 3:59:59 GMT;" />
			
			
		</head>
		<body>
		

Style is done to this text.

		</body>
</html>

If the expiration date and time is not included, the cookie is considered to be a session cookie and will be deleted soon after the user exits the browser.This is a type of temporary storage of information.

 

Setting Author Name

<!DOCTYPE html>
<html>
		<head>
			<title>Meta tags </title>
			<meta name="keywords" content="HTML, Meta Tags, Metadata" />
			<meta name="description" content="Learning about Meta Tags." />
			<meta name="author" content="Avinash" />
			
		</head>
		<body>
		

Hello HTML5!

		</body>
</html>

 

With this, we come to the end of this Cookies in HTML article. Check out the Web Development Certification Training by Edureka. Web Development Certification Training will help you learn how to create impressive websites using HTML5, CSS3, Twitter Bootstrap 3, jQuery and Google APIs and deploy it to Amazon Simple Storage Service(S3).

Got a question for us? Please mention it in the comments section of “What is HTML?” and we will get back to you.

Comments
0 Comments

Browse Categories

webinar REGISTER FOR FREE WEBINAR
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.