如何在php 7.0中设置cookie。设置Cookie无法在PHP中运行

时间:2017-10-23 07:53:21

标签: php

我想在我的PHP项目中设置cookie,我的代码是

setcookie("gi_cur", "USD", time() + (8886400 * 130), "/");

但这不起作用....目前我使用的是PHP 7.0版 有人可以帮帮我吗 感谢

1 个答案:

答案 0 :(得分:2)

bool setcookie ( string $name [, string $value = "" [, int $expire = 0 [, string $path = "" [, string $domain = "" [, bool $secure = false [, bool $httponly = false ]]]]]] )

<?php
$value = 'something from somewhere';

setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600);  /* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);
?>