Using Cookies with Authentication:
<?php
$cookie_name = “test”;
$cookie_value = “string”;
$cookie_expire = time()+10;
$cookie_domain = “127.0.0.1”;
$cookie_domain2 = “localhost”;
setcookie($cookie_name, $cookie_value, $cookie_expire, “/” ,$cookie_domain, 0);
setcookie($cookie_name, $cookie_value, $cookie_expire, “/” ,$cookie_domain2, 0);
?>
<HTML>
<HEAD>
<TITLE>Set Test Cookie</TITLE>
</HEAD>
<BODY>
<h1>Mmmmmmmm…cookie!</h1>
</BODY>
</HTML>
save this file as cookie.php and upload it to webserver.
<?php
if ($_COOKIE[test] == “string”) {
echo “Cookie Works now”;
}
else
echo “Cookies are not accessable”;
?>
save this file as access.php and upload it to webserver.
First Open cookie.php in browser it will set cookie and then open access.php it will show “Cookie Works now” for 10 seconds.