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.

About the author

Being the CEO and Founder of ClecoTech International, Mr. Ashish Prajapati is dedicated towards his aim of mentoring young startups into a full-fledged businesses. He is helping startups from America, Europe, India, and various other countries through proper guidance and the use of latest technologies to develop their innovation and ideas into definite realities.

Leave a Reply

Your email address will not be published. Required fields are marked *