How to set random cookie value using rand function in PHP
I don\'t want to change the value while page refreshed when it once assigned.. until cookie destroy
My
if(!isset($_COOKIE['lg'])) { setcookie('lg', rand(1,10000), time() + (86400 * 30), "/"); // 86400 = 1 day } echo $_COOKIE['lg'];
You can check if it is not set then set it.