HTML Meta Cookie - Example

HTML Meta tag can be used to set a cookie as shown below, which must be defined within the head section of an HTML document.

<meta http-equiv = "cookie" content = "userid = dummy123; expires = Saturday, 01-Jan-22 23:59:59 GMT;" />

Example

Run this on IDE

<!DOCTYPE html>
<html lang="en">
<head>
    <title>HTML Meta tag for cookies</title>
    <meta http-equiv = "cookie" content = "userid = dummy123; expires = Saturday, 01-Jan-22 23:59:59 GMT;" />
</head>
<body>
    <h1>Hello World!!</h1>
</body>
</html>

Overall

HTML meta tag example makes it easy to understand how a cookie can be set in action.

Related Links