PHP- Cookie Example


setcookie(name, value, expire);
setcookie("user", "aashish mittal", time()+60);// here 60 sec
$expire=time()+60*60*24*30;  //sec*min*hour*days ie cookie will expire in one month
setcookie("user", "aashish mittal”, $expire);

echo $_COOKIE["user"]."<br/>";
print_r($_COOKIE);          

function empty()

setcookie("user", "", time()-3600);//To delete cookie

Reactions: