【发布时间】:2017-12-13 20:45:39
【问题描述】:
在我网站的消息中心,用户可以互相评分和反馈。反馈和评级系统以弹出窗口的形式出现在屏幕上。我已经为此弹出窗口创建了 cookie,如果用户关闭弹出窗口或提交评分/反馈,则此弹出窗口仅在 24 小时后再次显示(Cookie 在 1 天后过期)。这里的问题是,一旦弹出 关闭/提交有关对特定用户进行评分的窗口,然后 cookie 不会让弹出窗口为聊天列表中的其他用户打开(Cookie 不会识别聊天列表中的用户)。我想用 cookie 来识别聊天列表中的用户。例如,如果我提交或关闭特定用户的弹出窗口,那么我只能在第二天给该特定用户提供反馈/评分。但我现在可以选择聊天列表中的其他用户并给出反馈/评分。
下面看代码。
<?
if($chain_author->id == Yii::$app->user->identity->id){
$form = ActiveForm::begin(['method' => 'POST', 'action' => ['/message/send-feed/'], 'options' => ['id' => 'send_feed_form', 'title' => Yii::t('title', 'evaluate'), 'style'=>'display:none']]);
// show star & feedback form
if(isset($_COOKIE['send-feed-form']))
{
echo 'show nothing';
}
else {
echo $this->render('/message/desktop/send-feed', ['chain' => $chain], ['style'=>'display:none']);
echo \frontend\widgets\FeedStar::widget(['type' => 'form', 'active_form' => $form]);
$button_options = (!$chain)?['class' => 'button button-send', 'disabled' => 'disabled']:['class' => 'button button-send'];
echo Html::submitInput(Yii::t('button', 'send'), $button_options);
echo Html::hiddenInput('chain', $cur_chain);
echo '<script type="text/javascript">';
echo '$(document).ready(function() {
$( function() {
$( "#send_feed_form" ).dialog({
modal: true,
width: 700,
height: 600,
});
});
});';
echo '</script>';
setcookie ('send-feed-form', 'yes', time() + 86400);
}
ActiveForm::end();
}
?>
【问题讨论】:
标签: javascript php cookies yii2