【发布时间】:2014-12-09 01:08:53
【问题描述】:
我正在尝试设置一个网页(使用 wordpress)来显示只能观看一次的视频。经过一些研究,似乎我最好的选择是通过 cookie 限制页面浏览量?
例如,我发现了这段代码,我觉得它可以解决问题:
if(!isset($_SESSION['mypage_view'])
{
$_SESSION['mypage_view'] = 1;
} else {
//check if this is not the first time the page has been viewed
if(isset($_SESSION['mypage_view'])) {
//not first time redirect
header('location: google.com');
session_write_close();
exit();
}
}
(来源:how do I show a php page just once only per user)
这将如何在 wordpress 中应用?或者有没有人有更好的解决方案来实现这一点?
感谢您的宝贵时间!
【问题讨论】:
-
使用一些数据库插入,因为 cookie 和会话可能会被破坏
-
您好,感谢您的快速回复,您能否为我指明有关此方面的更多帮助的方向?以前没用过数据库插入?