Search This Blog

set Cookies in php

<?php
/*

symtax:

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

*/


//it expires after 5 seconds
setcookie("user", "human", time()+5);
//it expires after 60 sec or 1 min
setcookie("user", "human", time()+60);
//it expires after 3600 sec or 1 hour
setcookie("user", "human", time()+3600);


//expire using varable
//it expires after 10 seconds
$time=10;
setcookie("visitor", "humans", time()+$time);

// note : normally "echo" not use in "setcookies" file
?>

output :


note :

1)no output display here
2)but cookies set

Share Links

Related Posts Plugin for WordPress, Blogger...