모바일 레이어 팝업에서 쿠키 관련 문제
본문
안녕하세요!
PC에서는 레이어 팝업에서 "24시간 동안 다시 열람하지 않습니다."가 잘 먹히는데,
모바일에서는 클릭을 해도 먹히지 않고 있습니다.
사이트 주소는 http://osanchurch.net 입니다.
개발자 페이지에서 나오는 에러는 다음과 같습니다.
index.html?device=mobile:58
Uncaught ReferenceError: set_cookie is not defined
at HTMLButtonElement.<anonymous> (index.html?device=mobile:58:9)
at HTMLButtonElement.dispatch (jquery.min.js:5:9843)
at y.handle (jquery.min.js:5:6626)
=============================
찍어보면, 58번째 라인은 newwin.inc.php에서 set_cookie(ck_name, 1, exp_time, g5_cookie_domain); 을 가리키고 있습니다.
mobile/newwin.inc.php 소스는 다음과 같습니다.
=====================================================
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$sql = " select * from {$g5['new_win_table']}
where '".G5_TIME_YMDHIS."' between nw_begin_time and nw_end_time
and nw_device IN ( 'both', 'mobile' )
order by nw_id asc ";
$result = sql_query($sql, false);
?>
<!-- 팝업레이어 시작 { -->
<div id="hd_pop">
<h2>팝업레이어 알림</h2>
<?php
for ($i=0; $nw=sql_fetch_array($result); $i++)
{
// 이미 체크 되었다면 Continue
if ($_COOKIE["hd_pops_{$nw['nw_id']}"])
continue;
?>
<div id="hd_pops_<?php echo $nw['nw_id'] ?>" class="hd_pops" style="top:10px;left:10px;width:95% !important;">
<div class="hd_pops_con" style="width:100% !important;">
<?php echo conv_content($nw['nw_content'], 1); ?>
</div>
<div class="hd_pops_footer">
<button class="hd_pops_reject hd_pops_<?php echo $nw['nw_id']; ?> <?php echo $nw['nw_disable_hours']; ?>"><strong><?php echo $nw['nw_disable_hours']; ?></strong>시간 동안 다시 열람하지 않습니다.</button>
<button class="hd_pops_close hd_pops_<?php echo $nw['nw_id']; ?>">닫기</button>
</div>
</div>
<?php }
if ($i == 0) echo '<span class="sound_only">팝업레이어 알림이 없습니다.</span>';
?>
</div>
<script>
$(function() {
$(".hd_pops_reject").click(function() {
var id = $(this).attr('class').split(' ');
var ck_name = id[1];
var exp_time = parseInt(id[2]);
$("#"+id[1]).css("display", "none");
set_cookie(ck_name, 1, exp_time, g5_cookie_domain);
});
$('.hd_pops_close').click(function() {
var idb = $(this).attr('class').split(' ');
$('#'+idb[1]).css('display','none');
});
$("#hd").css("z-index", 1000);
});
</script>
<!-- } 팝업레이어 끝 -->
조언 부탁드립니다.
답변 1
set_cookie 함수가 선언되지 않아서 그런데 모바일 헤더부분에서 해당 함수가 있는 /js/common.js 파일이 제대로 불러와지는지 한번 체크해보셔야 할것 같네요.