PHP COOKIES - Code

PHP SESSIONS Previous Next PHP ARRAYS


A cookie is often used to identify a user. a cookie is a variable that is stored on the visitor's computer.

Whenever this visitor's computer requests a page with a browser, it will send the cookie too.

The cookie is basically used to store information about the visitor like name of the visitor, which browser he is using, the version of the browser, the date of his last visit etc.

To set a cookie

The setcookie() function is used to set a cookie and must appear before the <html> tag.

Syntax

setcookie(name, value, expire, path, domain)

Filename: php / cookie.php


Code
<?php setcookie("user", "Harry Potter", time()+3600); ?>
<html>
<head>
<title>PHP COOKIE</title>
</head>
<body>
</body>
</html>

Running Step.


Type Url - https://localhost/php/cookie.php


Tags: PHP COOKIES PHP Code Programming Language


Was this helpful ?

Related Code