Using Cookies with Authentication in PHP

Using Cookies with Authentication:

$cookie_name = "test";
$cookie_value = "string";
$cookie_expire = time()+10;
$cookie_domain = "";
$cookie_domain2 = "localhost";
setcookie($cookie_name, $cookie_value, $cookie_expire, "/" ,$cookie_domain, 0);
setcookie($cookie_name, $cookie_value, $cookie_expire, "/" ,$cookie_domain2, 0);
<TITLE>Set Test Cookie</TITLE>
save this file as cookie.php and upload it to webserver.

if ($_COOKIE[test] == "string") {
echo "Cookie Works now";
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.

No comments:

Post a Comment