在PHP中使用cookie的条件语句会给我带来一些麻烦。
我想根据是否设置cookie来更改图像的状态。下面是我的代码(在MAIN.PHP文件中):
$cookie = "d_content_vote_".$databaseArray['id'];
if(!isset($_COOKIE[$cookie])) {
// display image 1 if cookie is not set
}
else {
// display image 2 if cookie is set
}
cookie值(时间戳的值)设置在./INCLUDES/RATING
我有一段代码,如果会话中没有cookie,就应该重定向用户。
if (isset($_GET['lang'])) {
if (in_array($_GET['lang'], $jezici)) {
$lang = $_GET['lang'];
// register the session and set the cookie
$_SESSION['lang'] = $lang;
setcookie("lang", $lang, time()
在php中,可以通过以下方式设置cookie
Setting new cookie
=============================
<?php
setcookie("name","value",time()+$int);
/*name is your cookie's name
value is cookie's value
$int is time of cookie expires*/
?>
Getting Cookie
=============================
<?php
echo $_
我正在尝试在wordpress中设置cookie。我的cookie设置如下:
<?php setcookie('test', 'test', 0, '/', '/'); ?>
在我的主题的header.php中,但当我去我的浏览器查看我的网站时,我得到这个错误
Warning: Cannot modify header information - headers already sent by (output started at /home/content/19/9468119/html/wp-content/th
我的页面有一个div,其中的内容是由PHP脚本编写的。
<div id="feastsaint"> <!-- Feast or Saint of the day -->
<?php
if(isset($_COOKIE["datetoday"])) {
echo $_COOKIE["datetoday"];
}
if(isset($_COOKIE["month"]) and isset($_COOKIE["d