i want to use cookie in web page and i want to use it for save any optional variables. but after use setcookie and refresh page isset()
The $_COOKIE data is read from the client's request data, and is not written immediately by setCookie(). This is normal behavior and should be incorporated into your program flow.
If you want the cookie data to be immediately available in your case, you might try something like this:
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!
";
else {
$user = "Alex Porter";
setcookie("user", $user, time()+3600);
echo "Welcome $user!
";
}